Link to home
Start Free TrialLog in
Avatar of ARW
ARW

asked on

eoAsyncExecute on ADO Stored Proc. not updating RecordSetState


When running a query asynchronously, using ExecuteOptions eoAsyncExecute, I thought I could check the state of the component, to see whether it is done or not, by checking RecordSetState.  Unfortunately, it is always an EmptySet.  I have the latest ADO patch for Delphi 5 and I am running against a SQL 7.0 database.  Is there a bug here or am I doing something wrong?

Thank you,

ARW
ASKER CERTIFIED SOLUTION
Avatar of Motaz
Motaz

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ARW
ARW

ASKER

Interesting implementation.

Thanks for pointing out to me that I had to set two properties of the execute options, not just one.  it still did not work though.  I had to change to client side cursor and ctKeyset cursor type.  Still did not work.  Finally, I noticed that your code snippet used an open.  My stored proc returns no records.  It calls a bunch others that update a temp table, so I used ExecProc method instead of Open.

You have to do an Open to get it to work.  Here is what mine looks like.

procedure TdmData.GetClientData;
var
work : tobjectstates;
begin
with spGetClientItems do
  begin
  Close;
  CommandTimeout := 3000;
//     spGetClientItems.ExecuteOptions := [eoAsyncfetch];
  Parameters.ParamValues['@CustID'] := CurrentClient;
  Parameters.ParamValues['@Modality'] := CurrentModality;
  Parameters.ParamValues['@StartDate'] := StartDate;
  Parameters.ParamValues['@EndDate'] := EndDate;
  Parameters.ParamValues['@SourceDB'] := SourceDB;
work := Tcustomadodataset(spGetClientItems).recordsetstate;
   open;  // was execproc
   while ( (RecordsetState = [stConnecting] ) OR
              (RecordsetState = [stExecuting] ) OR
             (RecordsetState = [stFetching]) ) do
      begin  // if get in here it is working
      Sleep(200);
      Application.ProcessMessages;
      end;    // while
   Close;
  End;
end;



Thanks for your help,

ARW
   
Avatar of ARW

ASKER

I seem to have the asynchronous behavior I am looking for, except when the query gets done, it closes itself without an explicit close by me.  Then I have to reopen it, which defeats the purpose.

Any ideas?