运行这段代码出现Cannot perform this operation on an open dataset
问题描述:
运行这段代码出现Cannot perform this operation on an open dataset
procedure Tfrm_in.edt_OKClick(Sender:TObject);
var y,m:String;
begin
y:=formatdatetime('yyyy',now);
m:=formatdatetime('m',now);
try
if (strtoint(edt_year.Text)>strtoint(y))or((strtoint(edt_year.Text)=strtoint(y))
and (strtoint(edt_month.Text)>=strtoint(m))) then
begin
showmessage('日期超前!');
exit;
end;
except
showmessage('请输入正确的月份!');
exit;
end;
month:='月进货'+edt_year.Text+'-'+edt_month.Text;
with data_month do
begin
commandtext:='select * from bookin where date like '+quotedstr(month+'-%');
active:=true;
end;
end;
答
在
commandtext:='select * from bookin where date like '+quotedstr(month+'-%');
上面加上if active then Close; 试试