with query1 do begin
close;
SQL.Add(…………) ;
open;
while not Eof do begin
Active := false;
Active := true;
ConsolidateGrid1.Cells[0,row] := inttostr(row);
ConsolidateGrid1.Cells[1,row] := Fields[0].AsString;
ConsolidateGrid1.Cells[2,row] := Fields[1].AsString;
ConsolidateGrid1.Cells[3,row] := Fields[2].AsString;
row := row + 1;
Next;
end;以上代码运行后,没有任何反应,也没有错误提示。当把“while not Eof do begin”和“Next”去掉以后,也就是说只显示一条数据的时候,运行没有任何问题。能把第一条数据显示出来。请问这是怎么回事?谢谢了先!
close;
SQL.Add(…………) ;
open;
while not Eof do begin
Active := false;
Active := true;
ConsolidateGrid1.Cells[0,row] := inttostr(row);
ConsolidateGrid1.Cells[1,row] := Fields[0].AsString;
ConsolidateGrid1.Cells[2,row] := Fields[1].AsString;
ConsolidateGrid1.Cells[3,row] := Fields[2].AsString;
row := row + 1;
Next;
end;以上代码运行后,没有任何反应,也没有错误提示。当把“while not Eof do begin”和“Next”去掉以后,也就是说只显示一条数据的时候,运行没有任何问题。能把第一条数据显示出来。请问这是怎么回事?谢谢了先!
open前加上query1.prepare;
去掉 Active := false; Active := true;没有必要我觉得。不知道你是做什么的。
query1.first;
你的begin....end.也不对。
with query1 do begin
close;
SQL.Add(…………) ;
open;
while not Eof do begin
Active := false;
Active := true;
ConsolidateGrid1.Cells[0,row] := inttostr(row);
ConsolidateGrid1.Cells[1,row] := Fields[0].AsString;
ConsolidateGrid1.Cells[2,row] := Fields[1].AsString;
ConsolidateGrid1.Cells[3,row] := Fields[2].AsString;
row := row + 1;
Next;
end;
end;
--当前记录设为第一条记录