Re: ProgressBar and ADO Dataset
- From: Brian Bushay TeamB <BBushay@xxxxxxxxx>
- Date: Fri, 23 Jun 2006 20:31:40 -0500
Hi I have tried to show a Progress bar on a simple form with twoWhen a recordset is opened with adAsyncFetch, only those records that are
ADODatasets, 1 and 2 respectively that displays the progress of
data being loaded from an Oracle Server into an Access table. To get the query to work quickly I have set the dataset 1 to eoAsyncFetch in the executeOptions. Further seems to me that there is some problem with the eof function of the dataset.
Herewith is the code:
procedure TForm1.Button1Click(Sender: TObject);
Var I : integer;
begin
AdoDataset1.open;
ADODataset2.Active:=True;
progressbar1.Min := 0;
I:=0;
MyCmpl_Status := False;
If ADODataSet1.RecordCount <> 0 then
begin
WHILE NOT MyCmpl_Status DO
begin
AdoDataset2.InsertRecord([ADODataSet1.FieldValues['SAMPLE_ID'],
I,
'Analytical Test',
ADODataSet1.FieldValues['COMPONENT'],
ADODataSet1.FieldValues['UNITS'],
ADODataSet1.FieldValues['VALUE_TYPE'],
ADODataSet1.FieldValues['NUMBER_VALUE'],
ADODataSet1.FieldValues['TEXT_VALUE'],
ADODataSet1.FieldValues['TIME_VALUE']]);
ADODataSet1.Next;
end;
end;
end;
procedure TForm1.ADODataSet1FetchProgress(DataSet: TCustomADODataSet;
Progress, MaxProgress: Integer; var EventStatus: TEventStatus);
begin
If ProgressBar1.Max<>MaxProgress then
ProgressBar1.Max := MaxProgress;
ProgressBar1.Position := Progress;
Application.ProcessMessages;
end;
procedure TForm1.ADODataSet1EndOfRecordset(DataSet: TCustomADODataSet;
var MoreData: WordBool; var EventStatus: TEventStatus);
begin
If EventStatus = esOK then
MyCmpl_Status := True //MyCmpl_Status is a Boolean Var
else
MyCmpl_Status := False;
end;
What I need to know is how to get the OnFetchProgress to fire! Because it does not seem to fire at all!
not returned during the initial fetch of records are asynchronously retrieved.
If all of the records are returned in the initial fetch, no asynchronous
fetching occurs, and the FetchProgress and the FetchComplete event are never
raised.
By default 50 rows are fetched in the first batch. You can change this by
setting the "Initial Fetch Size" property in the properties of the ADO
Recordset.
Initial Fetch Size property needs to be set after the recordset is created but
before it is opened. Use the OnRecordsetCreate event to do this.
ADODataSet1.RecordSet.Properties['Initial Fetch Size'].Value := 1;
Further, how do tell when am I at the end of the record set.You will need to use the OnFetchComplete event.
--
Brian Bushay (TeamB)
Bbushay@xxxxxxxxx
.
- Follow-Ups:
- Re: ProgressBar and ADO Dataset
- From: Tom Dalton
- Re: ProgressBar and ADO Dataset
- References:
- ProgressBar and ADO Dataset
- From: Tom Dalton
- ProgressBar and ADO Dataset
- Prev by Date: Re: Access Violation with msadce.dll
- Next by Date: Re: Simulating VB Nothing variant in Delphi
- Previous by thread: ProgressBar and ADO Dataset
- Next by thread: Re: ProgressBar and ADO Dataset
- Index(es):