Problem in creating ADO connection instance in thread 
Author Message
 Problem in creating ADO connection instance in thread

Hi,

I used #import directive to define and instantiating ADO objects. It
worked fine in my project. The problem came when I created a CWinthread
object and tried to create an ADO connection instance from the
declaration of ADODB::_ConnectionPtr by calling
conn.CreateInstance(__uuidof(ADODB::_Connection)) in the override
function InitInstance(). The creation of the connection instance failed
with a returned value -2147221008 to HRESULT. Has anybody known what was
wrong in creating ADO instance in thread?

Thanks

Nick



Tue, 18 Sep 2001 03:00:00 GMT  
 Problem in creating ADO connection instance in thread
Nick,

You need to initialise COM for the new thread before doing anything COM
related; e.g....

 HRESULT hr = CoInitializeEx(0, COINIT_APARTMENTTHREADED);

Regards
Jeremy

Quote:

>Hi,

>I used #import directive to define and instantiating ADO objects. It
>worked fine in my project. The problem came when I created a CWinthread
>object and tried to create an ADO connection instance from the
>declaration of ADODB::_ConnectionPtr by calling
>conn.CreateInstance(__uuidof(ADODB::_Connection)) in the override
>function InitInstance(). The creation of the connection instance failed
>with a returned value -2147221008 to HRESULT. Has anybody known what was
>wrong in creating ADO instance in thread?

>Thanks

>Nick



Tue, 18 Sep 2001 03:00:00 GMT  
 Problem in creating ADO connection instance in thread
I threw in :

 // Enable support for containment of OLE controls.
 AfxEnableControlContainer();

 // Init. the OLE/COM libraries.
 AfxOleInit();

at the start of my thread functon and the ADO stuff in the thread started to
work.  Don't know it this helps you but I hope it does...

--------------------------------------------------------------
Paul Kissel
RiverBend Software, Inc.

Phone/FAX: 541.383.9397
Postal: 20859 King Hezekiah Way, Bend, OR 97702

Quote:

>Hi,

>I used #import directive to define and instantiating ADO objects. It
>worked fine in my project. The problem came when I created a CWinthread
>object and tried to create an ADO connection instance from the
>declaration of ADODB::_ConnectionPtr by calling
>conn.CreateInstance(__uuidof(ADODB::_Connection)) in the override
>function InitInstance(). The creation of the connection instance failed
>with a returned value -2147221008 to HRESULT. Has anybody known what was
>wrong in creating ADO instance in thread?

>Thanks

>Nick



Thu, 20 Sep 2001 04:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. VC++ ADO _ConnectionPtr Create Instance Fail

2. Multi-Thread v.s. ADO Connection

3. Exception creating ADO Connection

4. Failure when create connection from other thread

5. Imlementing ADO.Connection interfaces VC++ problems

6. ATL / ADO problems while closing connection

7. Problem with ADO Connection

8. COM / ADO - Problems while closing connection

9. ADO Connection Problem with V++

10. ADO Connection problems

11. ADO connection problem

12. ADO connection problems

 

 
Powered by phpBB® Forum Software