How to use CoInitialize

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Bill Gage
Posts: 18
Joined: Fri 14 Oct 2005 17:23

How to use CoInitialize

Post by Bill Gage » Fri 14 Oct 2005 17:29

I am currently using SDAC in a service application using Asta for connectivity. I am using a persistent threading model so for each connection a new thread with the necessary datamodule with the SDAC TMSConnection and queries.
When I try to disconnect and then reconnect the TMSConnection I get the following error.

'Object was open..'
'CoInitialize has not been called.'

I have been told that I need to use CoInitialize and CoUnitialize. I have no clue how to do this with SDAC. Also I have no idea what units I need to include in my uses clause to be able to use the above methods. Any help is very appreciated.

Bill

Ikar
Posts: 1693
Joined: Thu 28 Oct 2004 13:56

Post by Ikar » Mon 17 Oct 2005 06:28

If you would like to use DbxSda in service, console or just at separate thread you need call CoInitialize for each thread before first connection. Also remember to call CoUnInitialize at the end of thread.

Bill Gage
Posts: 18
Joined: Fri 14 Oct 2005 17:23

What Unit?

Post by Bill Gage » Mon 17 Oct 2005 16:07

What unit do I need for CoInitialize?

Bill Gage
Posts: 18
Joined: Fri 14 Oct 2005 17:23

Post by Bill Gage » Mon 17 Oct 2005 22:42

btw ActiveX is the unit.

Ikar
Posts: 1693
Joined: Thu 28 Oct 2004 13:56

Post by Ikar » Tue 18 Oct 2005 07:06

Use ActiveX or Ole2 unit.

Post Reply