Page 1 of 1

How to use CoInitialize

Posted: Fri 14 Oct 2005 17:29
by Bill Gage
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

Posted: Mon 17 Oct 2005 06:28
by Ikar
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.

What Unit?

Posted: Mon 17 Oct 2005 16:07
by Bill Gage
What unit do I need for CoInitialize?

Posted: Mon 17 Oct 2005 22:42
by Bill Gage
btw ActiveX is the unit.

Posted: Tue 18 Oct 2005 07:06
by Ikar
Use ActiveX or Ole2 unit.