ProgressBar and ADO Dataset




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! Further, how do tell when am I at the end of the record set.

Regards Tom
.


Quantcast