gpt4 book ai didi

delphi - 将数百万条记录加载到字符串列表中可能会非常慢

转载 作者:行者123 更新时间:2023-12-03 15:04:16 27 4
gpt4 key购买 nike

如何快速地将数百万条记录从 tadotable 加载到字符串列表中?

procedure TForm1.SlowLoadingIntoStringList(StringList: TStringList);
begin
StringList.Clear;
with SourceTable do
begin
Open;
DisableControls;
try
while not EOF do
begin
StringList.Add(FieldByName('OriginalData').AsString);
Next;
end;
finally
EnableControls;
Close;
end;
end;

最佳答案

在你的循环中你得到了这个字段。在循环外搜索字段

procedure TForm1.SlowLoadingIntoStringList(StringList: TStringList); 
var
oField: TField;
begin
StringList.Clear;
with SourceTable do
begin
Open;
DisableControls;
try
oField:= FieldByName('OriginalData');
if oField<>Nil then
begin
while not EOF do
begin
StringList.Add(oField.AsString);
Next;
end;
end;
finally
EnableControls;
Close;
end;
end;
end;

关于delphi - 将数百万条记录加载到字符串列表中可能会非常慢,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8414454/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com