J
jimmy_che
Unregistered / Unconfirmed
GUEST, unregistred user!
有如下代码,我的意图是把FC1前两位为‘12’的显示在一个dbgrid上,但我这样写只显示一个,各位大虾帮我分析一下问题出在哪里,谢谢了
with query1 do
begin
close;
sql.Clear;
sql.Add('select FC41 from A_DBDA');
open;
while not eof do
begin
ss:=fieldbyname('fc41').AsString;
if leftstr(ss,2)='12' then tt:=ss else next;
query2.Close;
query2.SQL.Clear;
query2.SQL.Add('select fc41,fc42 from A_DBDA where fc41=:fc41');
query2.ParamByName('fc41').AsString:=tt;
query2.ExecSQL;
next;
end;
query2.Open;
end;
with query1 do
begin
close;
sql.Clear;
sql.Add('select FC41 from A_DBDA');
open;
while not eof do
begin
ss:=fieldbyname('fc41').AsString;
if leftstr(ss,2)='12' then tt:=ss else next;
query2.Close;
query2.SQL.Clear;
query2.SQL.Add('select fc41,fc42 from A_DBDA where fc41=:fc41');
query2.ParamByName('fc41').AsString:=tt;
query2.ExecSQL;
next;
end;
query2.Open;
end;