Problems access DB in services

Discussion of open issues, suggestions and bugs regarding usage of dbExpress drivers for SQL Server in Delphi and C++Builder
Post Reply
Andy02

Problems access DB in services

Post by Andy02 » Thu 18 Nov 2004 11:43

Hi all,
when I´m trying to open SQLConnection on app running as NT Service raises this error: Cannot access database. Please check databasename and net-connectivity OLE DB error occured. Code 800401F0h.
CoInitialize has not been called.

When the same app runs as an Exe I have no problems. Besides DBX-Connection with Borlands MSSQL-DBX-Driver that comes with D7 works.
I´m using D7 and dbexpsda.dll Ver 2.00 (tried also Ver 2.00.3), MSSQL 2000

Have you any advise what can be wrong ?

thanks
Andy

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

Re: Problems access DB in services

Post by Ikar » Thu 18 Nov 2004 12:44

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

Post Reply