Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Open database asynchronously in C++

21 views
Skip to first unread message

Rob Poels

unread,
Apr 8, 2009, 2:25:35 AM4/8/09
to

Hi all,

I am struggling with this for several days now, so I hope someone can help
me out.

I want to open a database in asynchronous mode, so my (C++) code looks like
this:


CDBPropSet dbinit(DBPROPSET_DBINIT);

dbinit.AddProperty(DBPROP_INIT_DATASOURCE, "MyDataSource");
dbinit.AddProperty(DBPROP_AUTH_USERID, "MyUserId");
dbinit.AddProperty(DBPROP_AUTH_PASSWORD, "MyPassword");
dbinit.AddProperty(DBPROP_INIT_CATALOG, "MyCatalog");
dbinit.AddProperty(DBPROP_INIT_PROMPT, (short)DBPROMPT_NOPROMPT);
dbinit.AddProperty(DBPROP_INIT_TIMEOUT, (short)20);
dbinit.AddProperty(DBPROP_INIT_GENERALTIMEOUT, (short)20);
dbinit.AddProperty(DBPROP_INIT_ASYNCH, DBPROPVAL_ASYNCH_INITIALIZE);

HRESULT hr = MyDataSource.Open("SQLNCLI10", &dbinit);

if (SUCCEEDED(hr))
{
. . .
}


The 'Open' function returns 'DB_S_ASYNCHRONOUS' which is ok. But now my
problem arises: how do I implement the callback so I know when opening the
database has finished.
I know I have to implement the 'IDBAsynchNotify' interface
(http://msdn.microsoft.com/en-us/library/ms718270(VS.85).aspx), but it does
not work for me; most probably because I am not doing it the right way. I
hope someone can provide me some C++ code how to do this, as I have been
searching the internet for hours now, without any success.


Thanks,

Robby

0 new messages