[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

eoAsyncExecute on ADO Stored Proc. not updating RecordSetState

Posted on 2001-06-19
3
Medium Priority
?
1,360 Views
Last Modified: 2007-11-27

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
0
Comment
Question by:ARW
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 7

Accepted Solution

by:
Motaz earned 300 total points
ID: 6209211
I turn AsyncExecute and AsyncFetch options to True and it works:

  AdoStoredProc1.Open;
  Memo1.Clear;


this is on a timer event:


  Caption:= IntToStr(Byte(AdoStoredProc1.State));
  if Byte(AdoStoredProc1.state) = 1 then
  begin
  with AdoStoredProc1 do
  while not Eof do
  begin
    Memo1.Lines.Add(Fields[0].AsString);
    Next;
  end;
  AdoStoredProc1.Close;
  end;
0
 

Author Comment

by:ARW
ID: 6212865
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
   
0
 

Author Comment

by:ARW
ID: 6216419
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?
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question