How to see progress of query execution during handle?

£可爱£侵袭症+ 提交于 2019-12-17 19:54:48

问题


I used the following code in delphi for handle :

procedure TForm1.ADOQuery1FetchProgress(DataSet: TCustomADODataSet; Progress,

  MaxProgress: Integer; var EventStatus: TEventStatus);

begin

    Progressbar1.Visible:=true;

    Progressbar1.Max:=MaxProgress;

    Progressbar1.Ppsitian:=Progress;

    Progressbar1.Visible:=false;

end;

but.... I can't see any effect (this code doesn't execute)

I want to show progress of query execution during when the user clicked a button for ٍُSEARCH in database from begining to finish filter in progressbar.

the button onclick codes :

with ADOQuery1 do

begin

SQL.Clear;

SQL.Add('select * from tbl1 where id = '+Edit1.Text);

Open;

end;

but i don't any mutation in the progress bar , as though don't write any code in OnFetchProgress event.

Did i represented you?


回答1:


you must set property ExecuteOptions to eoAsyncFetch before to call the open procedure

check this sample

with ADOQuery1 do
begin
 SQL.Clear;
 SQL.Add('select * from tbl1 where id = '+Edit1.Text);
 ExecuteOptions:=[eoAsyncFetch];
 Open;
end;


procedure TForm1.ADOQuery1FetchProgress(DataSet: TCustomADODataSet; Progress,
  MaxProgress: Integer; var EventStatus: TEventStatus);
begin
  ProgressBar1.Max      :=MaxProgress;
  ProgressBar1.Position :=Progress;
  Application.ProcessMessages;
end;


来源:https://stackoverflow.com/questions/4237112/how-to-see-progress-of-query-execution-during-handle

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!