views:

104

answers:

2

I'm working on some OLE DB code that runs queries on MS SQL Server via ICommand::Execute. I'm converting this code to operate asynchronously by setting the DBPROPVAL_ASYNCH_INITIALIZE property on the command before executing.

I'd prefer to register a IDBAsynchNotify sink so that my code can be notified of events, as opposed to polling or blocking via ISSAsynchStatus.

The documentation for ICommand::Execute does not show IConnectionPointContainer as an acceptable riid parameter, but the same document, when discussing the DB_S_ASYNCHRONOUS return code, suggests that it is possible to request an IConnectionPointContainer interface that I could use to register my event sink.

When I call ICommand::Execute, passing IID_IConnectionPointContainer as the riid parameter, I receive the E_NOINTERFACE error. I also tried setting the DBPROP_IConnectionPointContainer property before Execute but I received the same results.

If I have to, I'll use ISSAsynchStatus, but I'd much rather use IDBAsynchNotify. Is it possible?

A: 

See Performing Asynchronous Operations for SQL Native Client OLE Db specifics, including examples. The link says the only acceptable RIIDs are IID_IDBAsynchStatus and IID_ISSAsynchStatus, so my understanding that is that the programming model is pool based, not notification based.

Remus Rusanu
I'd read that document previously, and the behavior that I'm getting back from the code would certainly suggest this. I guess I'm curious as to whether any evidence exists that contradicts this.
Aaron Klotz
I'm speculating here, but have you tried asking for IID_IUnknown and then QueryInterface on the result for IID_IConnectionPointContainer?
Remus Rusanu
Just tried it, with the same result: E_NOINTERFACE.
Aaron Klotz
Bummer. I'm out of my element since OleDB was never a strong topic of mine, but I must say that async programming without callbacks doesn't fly too well...
Remus Rusanu
A: 

According to the response on this SQL Server Native Client blog post, "asynchronous notification programming model" was the fifth most important feature that was requested for the native client. I guess that answers the question. Hopefully the sqlncli team will address this sooner rather than later. I am easily annoyed by polling.

Aaron Klotz