H
hanhongfei
Unregistered / Unconfirmed
GUEST, unregistred user!
我做了一个查询客户销售情况的表单,下面是程序的一段代码:
with datamodulekehu.adoquery do
begin
close;
sql.Clear ;
sql.add('select sum(shuliang) as sl,sum(jine) as je from zouhuo');
sql.add('where khmc=1');
if checkbox1.checked=true then sql.add(' and nian=2');
if checkbox2.checked=true then sql.add(' and yue=3');
Parameters.parambyname('p1').value:=trim(edit1.text);
if checkbox1.checked=true then
Parameters.parambyname('p2').value:=strtofloat(trim(edit2.text));
if checkbox2.checked=true then
Parameters.parambyname('p3').value:=strtofloat(trim(edit3.text));
try
open;
except
execsql;
end;
edit4.text:=fieldbyname('sl').asstring;
edit5.text:=fieldbyname('je').asstring;
end;
//表格显示//
with datamodulekehu.adoqueryzouhuo do
begin
close;
sql.clear;
sql.add('select * from zouhuo');
sql.add('where khmc=1');
if checkbox1.checked=true then sql.add(' and nian=2');
if checkbox2.checked=true then sql.add(' and yue=3');
Parameters.parambyname('p1').value:=trim(edit1.text);
if checkbox1.checked=true then
Parameters.parambyname('p2').value:=strtofloat(trim(edit2.text));
if checkbox2.checked=true then
Parameters.parambyname('p3').value:=strtofloat(trim(edit3.text));
try
open;
except
execsql;
end;
end;
当查询时为空(既没有业务发生时),在查询别的客户时出错!提示eof或bof 有一为空
盼望回复!!![][]
我的ado已经是2.7(在微软网站下载的)
with datamodulekehu.adoquery do
begin
close;
sql.Clear ;
sql.add('select sum(shuliang) as sl,sum(jine) as je from zouhuo');
sql.add('where khmc=1');
if checkbox1.checked=true then sql.add(' and nian=2');
if checkbox2.checked=true then sql.add(' and yue=3');
Parameters.parambyname('p1').value:=trim(edit1.text);
if checkbox1.checked=true then
Parameters.parambyname('p2').value:=strtofloat(trim(edit2.text));
if checkbox2.checked=true then
Parameters.parambyname('p3').value:=strtofloat(trim(edit3.text));
try
open;
except
execsql;
end;
edit4.text:=fieldbyname('sl').asstring;
edit5.text:=fieldbyname('je').asstring;
end;
//表格显示//
with datamodulekehu.adoqueryzouhuo do
begin
close;
sql.clear;
sql.add('select * from zouhuo');
sql.add('where khmc=1');
if checkbox1.checked=true then sql.add(' and nian=2');
if checkbox2.checked=true then sql.add(' and yue=3');
Parameters.parambyname('p1').value:=trim(edit1.text);
if checkbox1.checked=true then
Parameters.parambyname('p2').value:=strtofloat(trim(edit2.text));
if checkbox2.checked=true then
Parameters.parambyname('p3').value:=strtofloat(trim(edit3.text));
try
open;
except
execsql;
end;
end;
当查询时为空(既没有业务发生时),在查询别的客户时出错!提示eof或bof 有一为空
盼望回复!!![][]
代码: