Hello,
I use MSConnection in Service (TService). When I set MSConnection.Connected to True in design time then all running ok, but when MSConnection.Connected is False in design time and I use MSConnect.Connect in TService.ServiceExecute event then TService not start and in application log is error "OLE DB error occured. Code 800401F0h. CoInitialize has not been called.."
How is possible to connect MSConnection in runtime in TServiceApplication?
SDAC 4.70.0.50
Delphi 7
NativeClient for SQL2008
jabu
Problem with MSConnection.Connect in Service (TService).
You should not set MSConnection.Connected to True in design time, instead use the following code to connect to SQL server in runtime:
Code: Select all
MSConnection.Connect;Re: Problem with MSConnection.Connect in Service (TService).
Try this:jabu wrote:Hello,
I use MSConnection in Service (TService). When I set MSConnection.Connected to True in design time then all running ok, but when MSConnection.Connected is False in design time and I use MSConnect.Connect in TService.ServiceExecute event then TService not start and in application log is error "OLE DB error occured. Code 800401F0h. CoInitialize has not been called.."
How is possible to connect MSConnection in runtime in TServiceApplication?
SDAC 4.70.0.50
Delphi 7
NativeClient for SQL2008
jabu
procedure TService.ServiceExecute(Sender: TService);
begin
CoInitializeEx(NIL,COINIT_MULTITHREADED);
..
// your code
..
CoUnInitialize;
end;