procedure TForm1.Button1Click(Sender: TObject);
var
loList: TStringList;
i, j: Integer;
lsFieldStr: String;
loDt1, loDt2: TDateTime;
begin
j := 0;
ProgressBar1.Min := 0;
if not AQry_BD.Active then AQry_BD.Open;
loDt1 := Now;
ProgressBar1.Max := AQry_BD.RecordCount;
loList := TStringList.Create;
try
AQry_BD.First;
AQry_BD.DisableControls;
while not AQry_BD.Eof do
begin
lsFieldStr := '';
for i := 0 to AQry_BD.FieldCount - 1 do
begin
lsFieldStr := lsFieldStr + Trim(AQry_BD.Fields.AsString) + '|';
end;
loList.Add(lsFieldStr);
j := j + 1;
ProgressBar1.Position := j;
AQry_BD.Next;
end;
AQry_BD.EnableControls;
loList.SaveToFile('DemoFile.dat');
loDt2 := Now;
ShowMessage('数据导出时间为:' + DateTimeToStr(loDt1 - loDt2));
finally
loList.Free;
end;
end;
我现在是通过TStringList导出,发现直写文件更慢,不知TStringList能不能支持上亿条记录.