Accessing a DB from thread

Hi, I used to have the db connection in my dialog:

But I have  a lot of data to transfer, so I have put it in a thread, like this, creating the thread from the dialog:

Then the implementation of the function looks like this:

UINT WorkerThreadProc( LPVOID Param )
_ConnectionPtr m_DBConn;
m_DBConn.CreateInstance( __uuidof( Connection ) );

** I could create the instance to the _ConnectionPtr, when I did it in the dialog class, but not hire in the worker thread function. Anyone have any good idea why ?
Who is Participating?
AlexFMConnect With a Mentor Commented:
You need to call CoInitialize or CoInitializeEx in the beginning of worker thread, and CoUninitialize/CoUninitializeEx in the end.
win32Author Commented:
Dough.. right
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.