Re: ProgressBar and ADO Dataset



Hi Brian,

Thanks for you reply. I doubt that the intial fetch will have fetched all
the records (my test data set > 25000 records). When I used the conventional
progressbar mechanism you can see it fetching the records and then proceding
to write them to the table on the local machine. Again, this was the idea
of moving to the OnFetchProgress event to show thw progress to the user. I
will give it another try.

WRT the OnFetchComplete event it also did not seem to fire as expected as
you may well have seen the code to check for the end of the file although it
was put on the OnEndofrecordset I previously tried it on the OnFetchComplete
and noted that it never stopped the loop I was using to write the recs to
the local table.

Regards
Tom Dalton
"Brian Bushay TeamB" <BBushay@xxxxxxxxx> wrote in message
news:dm1p92t8sdm9m0de6nk0fug88cf4ced80t@xxxxxxxxxx


Hi I have tried to show a Progress bar on a simple form with two
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!
When a recordset is opened with adAsyncFetch, only those records that are
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


.


Quantcast