CoInitialize sets up the COM infrastructure on a thread. Therefore you call it per-thread, not per database or instance. Ideally though call CoInitializeEx instead.
Note that if you call it again it will return a successful failure (S_FALSE
).
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I am testing with MSSQL server 2008. I have configured multiple database in my application. When I try to connect the second database it throws HR error "0x800401f0" which says CO_E_NOTINITIALIZED and it was thrown when trying to create co-create instance for the second database connection. But already we have coInitialized when we connect default/first database. So do we need to Coinitialize per database connection or per instance?
CoInitialize sets up the COM infrastructure on a thread. Therefore you call it per-thread, not per database or instance. Ideally though call CoInitializeEx instead.
Note that if you call it again it will return a successful failure (S_FALSE
).
Hi @parvathy priya ,
This is more a programming problem than a SQL Server database connection problem, and perhaps more effective help can be obtained in the appropriate forum.
Check the Remarks of the document: CoInitialize function
And please check the following posts if help:
https://stackoverflow.com/questions/49481853/cocreateinstance-in-the-mmdevice-api-returns-error-code-0x800401f0
https://stackoverflow.com/questions/9286600/when-do-i-need-to-call-coinitialize-in-this-scenario