delphi 中出现cannot perform this operation on a closed dataset问题procedure Tfrm_bmxx.FormShow(Sender:TObject);begindata1.ADOQYbmxx.Active:=false;with data1.ADOQYbmxx dobeginclose;sql.Clear;sql.text := 'select * from 部门表'; // sql.Add('sele

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/17 12:48:03

delphi 中出现cannot perform this operation on a closed dataset问题procedure Tfrm_bmxx.FormShow(Sender:TObject);begindata1.ADOQYbmxx.Active:=false;with data1.ADOQYbmxx dobeginclose;sql.Clear;sql.text := 'select * from 部门表'; // sql.Add('sele
delphi 中出现cannot perform this operation on a closed dataset问题
procedure Tfrm_bmxx.FormShow(Sender:TObject);
begin
data1.ADOQYbmxx.Active:=false;
with data1.ADOQYbmxx do
begin
close;
sql.Clear;
sql.text := 'select * from 部门表'; // sql.Add('select * from 部门表');
open;
data1.ADOQYbmxx.Active:=true;
if data1.ADOQYbmxx.FieldByName('部门编号').Value= null then
begin
application.MessageBox('数据库中没有数据,请添加数据','提示',64);
speedbutton1.Click;
end;
end;
end;
每次运行时点击dbgrid时出现此错误,且显示不了数据库里的信息.

delphi 中出现cannot perform this operation on a closed dataset问题procedure Tfrm_bmxx.FormShow(Sender:TObject);begindata1.ADOQYbmxx.Active:=false;with data1.ADOQYbmxx dobeginclose;sql.Clear;sql.text := 'select * from 部门表'; // sql.Add('sele
建议在dbgrid的onclick事件里打断点跟踪一下
或者在调试模式下运行,看看出错时代码停在哪
你这段代码虽然罗嗦,但是执行没有问题,而且这段代码是在窗体create完成后显示的时候执行的,不是点击dbgrid的时候执行的