我想在客户端(通过网络)读取blobfield(使用blobstream),但在获取数据时应用程序会冻结。如何在不冻结的情况下读取blobfield,并且使用进度条显示百分比(我正在使用Delphi和Firebird)。
我正在使用uniquery组件。我从http://forums.devart.com/viewtopic.php?t=14629找到了以下代码,但它无法正常工作:
在repeat-until循环的第一步中,Blob.Read方法读取了整个流,因此它无法正常工作。
我正在使用uniquery组件。我从http://forums.devart.com/viewtopic.php?t=14629找到了以下代码,但它无法正常工作:
const
BlockSize= $F000;
var
Blob: TBlob;
Buffer: array of byte;
p: pointer;
pos, count: integer;
UniQuery1.SQL.Text:= 'select * from TABLE1 where FIELD_ID = 1';
UniQuery1.Open;
blob:= uniquery1.GetBlob('DATA');
SetLength(buffer, blob.Size);
ProgressBar1.Position:= 0;
Application.ProcessMessages;
repeat
count:= Blob.Read(pos, blocksize, p);
ProgressBar1.Position:= Round(pos/Blob.Size * 100);
pos:= pos + count;
p:= pointer(integer(p) + count);
Application.ProcessMessages;
until count < blocksize;
PS:我已经设置了UniQuery的选项:
cacheblobs:= false;
streamedblobls:= true;
deferredblobread:= true;
在repeat-until循环的第一步中,Blob.Read方法读取了整个流,因此它无法正常工作。
TBlobStream
子类,并像@whosrdaddy所说,将您的DB内容放到单独的工作线程中。 - TLama