本人刚试着用D5的ADO连接sql数据库的小程序调试也通了,但在运行过程中,出现了如下错误:Cannot perform this operation on an open dataset,但用access数据库就不会出现这种错误.
出错的程序段如下:
with Tadoquery.Create(nil) do begin
connection:=adoconnection1;
sql.Clear;
sql.add('select * from bm where id='+inttostr(r^));
open;
……
if …… then begin
sql.Clear;
sql.add('select * from ……‘);//开始出错
open;
……
free;
end;
请问如何在程序中关闭已打开的数据表
出错的程序段如下:
with Tadoquery.Create(nil) do begin
connection:=adoconnection1;
sql.Clear;
sql.add('select * from bm where id='+inttostr(r^));
open;
……
if …… then begin
sql.Clear;
sql.add('select * from ……‘);//开始出错
open;
……
free;
end;
请问如何在程序中关闭已打开的数据表
adoconnection1.connected := false;
或者是在设计阶段将adoconnection的connected属性设置为false;
sql.close;
close;//加上这句就对了。
sql.Clear;
sql.add('select * from ……‘);//开始出错
open;
……