具体问题如下:
公共函数:
function jczf(sql_str:strin):integer;
begin
with pub.qjc do
begin
close;
sql.clear;
sql.add(sql_str);
try
open;
if recordcount>0 then
result:=0 else result:=-1;
except
result:=-1;
raise;
end;
end;
end;在软件应用中调用函数(通过一个edit或button控件--回车)如下:
if jczf('select * from information where code=''if_yjk_zd'' and set_value=''1'' ')=0 then
begin
...............
end;
就会提示错误信息如下:(通过一个edit或button控件--回车之后会出现)
QJC:cannot perform this operation on an open datset
好像是不能怎样一个打开的数据????不知是咋个搞的有时又出现有时又不出现好像很不稳定!
然后退出系统的时候也有错误提示但是如果没有上面的错误提示信息退出时也不会出现错误提示信息如下:
Application Error Exception EdatabaseError in module Vcldb50.bpl at 0008df0 QJC:cannot Perform this operation on an open dataset不知何故望高手指点我想了好长时间也没有想出来哎呀!!!!
公共函数:
function jczf(sql_str:strin):integer;
begin
with pub.qjc do
begin
close;
sql.clear;
sql.add(sql_str);
try
open;
if recordcount>0 then
result:=0 else result:=-1;
except
result:=-1;
raise;
end;
end;
end;在软件应用中调用函数(通过一个edit或button控件--回车)如下:
if jczf('select * from information where code=''if_yjk_zd'' and set_value=''1'' ')=0 then
begin
...............
end;
就会提示错误信息如下:(通过一个edit或button控件--回车之后会出现)
QJC:cannot perform this operation on an open datset
好像是不能怎样一个打开的数据????不知是咋个搞的有时又出现有时又不出现好像很不稳定!
然后退出系统的时候也有错误提示但是如果没有上面的错误提示信息退出时也不会出现错误提示信息如下:
Application Error Exception EdatabaseError in module Vcldb50.bpl at 0008df0 QJC:cannot Perform this operation on an open dataset不知何故望高手指点我想了好长时间也没有想出来哎呀!!!!
换成ACCESS数据库
Adoconnection.Close;
Adoconnection.Open;
using : boolean;function jczf(sql_str:strin):integer;
begin
if pub.using then
begin
ShowMessage('函数使用中');
Reult := -2;
Exit;
end;Pub.Using := true;
try
with pub.qjc do
begin
close;
sql.clear;
sql.add(sql_str);
try
open;
if recordcount>0 then
result:=0 else result:=-1;
except
result:=-1;
raise;
end;
end;
finally
pub.using := false
end;
end;
end;
function jczf(sql_str:strin):integer;
begin
with pub.qjc do
begin
close;
sql.clear;
sql.add(sql_str);
try
open;
if recordcount>0 then
result:=0 else result:=-1;
except
result:=-1;
raise;
end;
end;
end;
是关闭了又打开的呀是不???close;
这是dataset的状态问题。跟DELPHI没关系。不要乱戴帽子。