procedure TForm1.Button1Click(Sender: TObject);
var
i:integer;
begin
for i:=10 to 11 do
begin
with adoquery1 do
begin
close;
sql.Clear;
// showmessage(inttostr(i)) ;
sql.add('select sum(jz) from ylrkb where rq >=''2013-'+inttostr(i)+'-01'' and rq<''2013-'+inttostr((i+1))+'-01''');
// showmessage('2013-'+inttostr(i)+'-01') ;
open;
end;
end
end;
如上代码所示 ,希望通过循环的方式来查询数据,并把数据写到DBgrid控件中,但是每次运行后只显示一个数据,求解答,非常感谢
var
i:integer;
begin
for i:=10 to 11 do
begin
with adoquery1 do
begin
close;
sql.Clear;
// showmessage(inttostr(i)) ;
sql.add('select sum(jz) from ylrkb where rq >=''2013-'+inttostr(i)+'-01'' and rq<''2013-'+inttostr((i+1))+'-01''');
// showmessage('2013-'+inttostr(i)+'-01') ;
open;
end;
end
end;
如上代码所示 ,希望通过循环的方式来查询数据,并把数据写到DBgrid控件中,但是每次运行后只显示一个数据,求解答,非常感谢


