procedure TForm1.Button1Click(Sender: TObject);
var mcht:string;
use:integer;
begin
adoquery1.Close; //连接transinfo数据库表
adoquery1.SQL.clear;
adoquery1.SQL.Add('select mchtid,count(*) as num from transinfo group by mchtid');
adoquery1.Open;
adoquery1.First;
while not adoquery1.Eof do
begin
use:=adoquery1.fieldbyname('num').AsInteger;
mcht:=adoquery1.fieldbyname('mchtid').AsString;
adoquery2.Close;
adoquery2.SQL.Clear;
adoquery2.SQL.Add('update POS_hc set lest=lest-use where mchtid=''mcht''');
adoquery2.ExecSql;
adoquery1.Next;
end;
end;
应该是这个,可是为什么陷入死循环呢?