Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to realize PROGRESSBAR that shows loading of records in Dataset?

Status
Not open for further replies.

Delphard

Programmer
Jul 22, 2004
144
RS
Large Dataset, so it is desirable to have ProgressBar that shows progress of record loading...

How to realize that?
 
well that depends on what database components your are using.

the ADO components (like ADOQueury and ADOTable) have an OnFetchProgress event handler.

/Daddy

-----------------------------------------------------
What You See Is What You Get
Never underestimate tha powah of tha google!
 
Yes, I use ADOQuery.
And what about OnFetchProgress event handler, how to use them in this purpose?
 
Taken from an old DelphiPages.com discussion:
TFetchProgressEvent = procedure(DataSet: TCustomADODataSet; Progress, MaxProgress: Integer; var EventStatus: TEventStatus) of object;
property OnFetchProgress: TfetchProgressEvent;

Description

Write an OnFetchProgress event handler to take specific action during an asynchronous data retrieval operation. The OnFetchProgress event fires periodically during the data retrieval to provide indications of its progress. Create a handler for this event to react to this periodic notification, such as providing the user with a visual indication of the progress of the data retrieval.

DataSet is the ADO dataset component that triggered the OnFetchProgress event. This dataset component also contains the recordset in question.

Progress is the number of records that have been received since the data fetching operation began.

MaxProgress is the total number of records to be retrieved by the operation.

Progress and MaxProgress used together to get percent complete. For example, Progress divided by MaxProgress and multiplied by 100 yields the percent completion of the data fetching.

procedure TForm1.ADODataSet1FetchProgress(DataSet: TCustomADODataSet; Progress, MaxProgress: Integer; var EventStatus: TEventStatus);
begin
Caption := 'Percent complete: ' +
IntToStr(Trunc(Progress / MaxProgress * 100)) + '%';
Application.ProcessMessages;
end;
 
'The OnFetchProgress event fires periodically during the data retrieval...'
The only problem is that OnFetchProgress don't fires when I open ADOQuery?!
 
You need to change the TADOQuery.CacheSize property. By default it is 1, meaning that TADOQuery.Open returns after retrieving 1 record. Each call to Next, retrieves another record.

If you increase this to, say, 20000, you should get at least some OnFetchProgress events being fired.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top