Hi,
I'm testing MS SQL dbExpress driver (dbexpsda.dll V2.50.5 trial). But when my Delphi7 application try to open a TSQLConnection it launch an exception: Ole DB error ocurred. Code 800401F0h. CoInitialize has not been called.
This application don't have this problem with Borland MSSQL driver.
thanks,
Ricardo
OLE DB Error. CoInitialize has not been called
-
- Posts: 7
- Joined: Sat 08 Jul 2006 06:03
- Location: Durban, South Africa
I have a data access module that is created per user in a user object.
In the before connect event on a dbxpress connection I call CoInitialize, is this the correct place to be doing the call OR should the call be done in each thread accessing the user object?
Also curious to find out why the core lab driver has this requirement compared to the built in borland one?
In the before connect event on a dbxpress connection I call CoInitialize, is this the correct place to be doing the call OR should the call be done in each thread accessing the user object?
Also curious to find out why the core lab driver has this requirement compared to the built in borland one?
> In the before connect event on a dbxpress connection I call
> CoInitialize, is this the correct place to be doing the call OR
> should the call be done in each thread accessing the user object?
CoInitialize must be called one time in each thread that connects to the server. Putting CoInitialize in OnBeforeConnect event may lead to multiple calling of this function, but this shouldn't cause any problems. But you should take care about calling CoUnInitialize. It must be called only once before terminating the thread.
> Also curious to find out why the core lab driver has this
> requirement compared to the built in borland one?
Core Lab's driver uses OleDB mechanism to access MS SQL Server. We use this low-level mechanism because it has high-performance and is very good documented. This mechanism differs from Borland's one. That's why Core Lab driver for dbExpress requires a call to CoInitialize.
> CoInitialize, is this the correct place to be doing the call OR
> should the call be done in each thread accessing the user object?
CoInitialize must be called one time in each thread that connects to the server. Putting CoInitialize in OnBeforeConnect event may lead to multiple calling of this function, but this shouldn't cause any problems. But you should take care about calling CoUnInitialize. It must be called only once before terminating the thread.
> Also curious to find out why the core lab driver has this
> requirement compared to the built in borland one?
Core Lab's driver uses OleDB mechanism to access MS SQL Server. We use this low-level mechanism because it has high-performance and is very good documented. This mechanism differs from Borland's one. That's why Core Lab driver for dbExpress requires a call to CoInitialize.
I found a more elegant solution as the whole problem originated from using Intraweb, I rather get Intraweb to initialise com for me. This sorts it out nicely.
When using your MS SQL DbExpress driver or ADO driver with Intraweb, you must set the ComInitialization property in the ServerController to ‘ciMultiThreaded’.
This will eliminates the "CoInitialize has not been called" error.
When using your MS SQL DbExpress driver or ADO driver with Intraweb, you must set the ComInitialization property in the ServerController to ‘ciMultiThreaded’.
This will eliminates the "CoInitialize has not been called" error.