Additional
dbCAP
AnyDAC
ThinDAC
NCOCI8
Topic: TADStoredProc / AsyncCmd / Sql server 2000
TADStoredProc / AsyncCmd / Sql server 2000
Posted: 2007/05/15 20:36
 
Dmitry,

I am trying to execute a stored proc that returns a result set Asynchronously.

I set ASyncCmdMode to amAsync, AsyncCmdTimeout to 50000 and as soon as execute Open, I get the following error:

Connection is busy with results for another hstmt

If I set the Asynccmdmode to amBlocking it works fine

What am I doing wrong?

Thanks,

Isi
Re:TADStoredProc / AsyncCmd / Sql server 2000
Posted: 2007/05/16 08:17
 
Hello Isidro

I think, that is bug in AnyDAC. I will appreciate, if you will give me following info:
- in general, the best, will be if you will give me test example;
- how many result sets your procedure is returning ?
- is fiMeta in FetchOptions.Items ? If yes, try to exclude;
- does ADStoredProc have any event handlers ?

Regards,
Dmitry
Re:TADStoredProc / AsyncCmd / Sql server 2000
Posted: 2007/05/19 08:47
 
Dmitry,

I decided to create at runtime a IADPhysCommand and it does '.Open' a stored procedure asynchronously. I needed to know when the stored proc finished so I went ahead and implemented:


   TMyAsyncHandler = class(TInterfacedObjectIADStanAsyncHandler)     procedure HandleFinished(const AInitiatorIADStanObjectAStateTADStanAsyncStateAExceptionException);   end;



My problem now is that I don't know how to get the underlaying dataset so I can traverse through the records within the Asynchandler

How do you do that?

Also, I would like to invoke a specific function when the handler finishes, is there a way to pass an extra parameter like a handle to this function?

Regards,

Isi R.
Re:TADStoredProc / AsyncCmd / Sql server 2000
Posted: 2007/05/20 01:04
 
Hello Isidro

1) To fetch data using IADPhysCommand, you will need:


 var   oTabTADDatSTable; .........   // after IADPhysCommand is open   oTab := TADDatSTable.Create;   oCmd.Define(oTab);   oCmd.Fetch(oTab);



After that you can traverse through oTab directly. See multiple demos for DatS layer. Or you can attach TADClientDataSet to the oTab:


   ADClientDataSet1.AttachTable(oTabnil);   ADClientDataSet1.Open;



2) About user data and handler. Why just not add required field members to the TMyAsyncHandler ? There is no other way to submit user data to the handler.

Regards,
Dmitry