invalid class typecast

xuxugr 2009-06-21 10:40:12
var
I: Integer;
begin
try
with adoquery3 do
begin
close;
sql.Clear;
sql.Add('select * from tba_bmbm');
open;
end;
except
on E:Exception do
begin
for i:=0 to Frm.ComponentCount-1 do
begin
if Frm.Components[i] is tadoquery then
if (Frm.Components[I] as tadoquery).State <> dsInactive then
(Frm.Components[I] as tadoquery).Connection:=nil;
data1.adoConnection1.Close;
data1.adoConnection1.Open;
(Frm.Components[I] as tadoquery).Connection:=data1.adoConnection1;
end;
end;
end;
end;

哪错了呀
...全文
72 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
starluck 2009-06-22
  • 打赏
  • 举报
回复
[Quote=引用楼主 xuxugr 的帖子:]
var
I: Integer;
begin
try
with adoquery3 do
begin
close;
sql.Clear;
sql.Add('select * from tba_bmbm');
open;
end;
except
on E:Exception do
begin
for i:=0 to Frm.ComponentCount-1 do
begin


就是沒注意BEGIN END
if Frm.Components[i] is tadoquery then
if (Frm.Components[I] as tadoquery).State <> dsInactive then
(Frm.Components…
[/Quote]
xuxugr 2009-06-22
  • 打赏
  • 举报
回复
这我倒是没在意,一会试试
bdmh 2009-06-22
  • 打赏
  • 举报
回复
你的if语句有问题,修改如下

if Frm.Components[i] is tadoquery then
begin
if (Frm.Components[I] as tadoquery).State <> dsInactive then
begin
(Frm.Components[I] as tadoquery).Connection:=nil;
data1.adoConnection1.Close;
data1.adoConnection1.Open;
(Frm.Components[I] as tadoquery).Connection:=data1.adoConnection1;
end;
end;
xuxugr 2009-06-22
  • 打赏
  • 举报
回复
for i:=0 to Frm.ComponentCount-1 do
begin
if Frm.Components[i] is tadoquery then
if (Frm.Components[I] as tadoquery).State <> dsInactive then
(Frm.Components[I] as tadoquery).Connection:=nil;
data1.adoConnection1.Close;
data1.adoConnection1.Open;
(Frm.Components[I] as tadoquery).Connection:=data1.adoConnection1;
end;


我看到有的贴子说ADOConnection1.Execute,我不知道怎么改

2,497

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 数据库相关
社区管理员
  • 数据库相关社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧