本文介绍了处理期间如何查看查询执行进度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在 delphi 中使用了以下代码作为句柄:
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)
我想在用户单击数据库中的 ٍُSEARCH 按钮时显示查询执行的进度,从开始到完成过滤器在进度条中.
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.
按钮点击代码:
with ADOQuery1 do
begin
SQL.Clear;
SQL.Add('select * from tbl1 where id = '+Edit1.Text);
Open;
end;
但我在进度条中没有任何突变,好像没有在 OnFetchProgress 事件中编写任何代码.
but i don't any mutation in the progress bar , as though don't write any code in OnFetchProgress event.
我代表你了吗?
推荐答案
你必须设置属性 ExecuteOptions
到 eoAsyncFetch
在调用 open 过程之前
you must set property ExecuteOptions
to eoAsyncFetch
before to call the open procedure
检查此示例
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;
这篇关于处理期间如何查看查询执行进度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!