Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

delphi - How to see progress of query execution during handle?

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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;

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...