Board index » delphi » Error connecting to database-NT Service-MTS-COM

Error connecting to database-NT Service-MTS-COM

Error connecting to database-NT Service-MTS-COM
I have created a Windows NT Service using
Delphi 5 Enterprise on an NT 4 Client computer.
This service is supposed to retrieve rows from
a table and with the table information create
a thread for the three first rows of the table.
Each of these threads should create a COM object
developed using the same Delphi 5 Enterprise.
These COM objects would then connect to the
database using ADOConnection and ADOQuery and
retrieve information to generate a QuickReport
saved to a certain subdirectory.
If only one thread is run, it works fine. But
if the three threads them are created almost at
the same time, I get an error for one of them (if
it helps, the error is "The exception unknown
software exception (0x0eedfade) occured in the
application at location 0x77f1d479"). The error
can be raised by any of the three COM Objects
created, so it looks like it is a problem with
concurrency or something...
I tried to debug the MTS COM Objects that were
created and found out that the error is raised
when the COM object is trying to connect to the
database.
The error occurs either if I use a connection
string or a UDL file.
I tried CoInitializeEx(nil, COINIT_MULTITHREADED)
in several places but it also didn't work.
Any help will be appreciated!

Thank you,
Thiago

 

Re:Error connecting to database-NT Service-MTS-COM


Apply this pattern when using COM from a thread:

proc TFooThread.Execute;
begin
  CoInitialize (nil);
  AcquireInterfacePointers;
  UserInterfacePointers;
  FreeInterfacePointers;
  CoUninitialize;
end;

--
have fun
Binh Ly
http://www.techvanguards.com

"Thiago de Almeida" <thiago_ba...@yahoo.com> wrote in message
news:3b54c100$1_1@dnews...

Quote
> Error connecting to database-NT Service-MTS-COM
> I have created a Windows NT Service using
> Delphi 5 Enterprise on an NT 4 Client computer.
> This service is supposed to retrieve rows from
> a table and with the table information create
> a thread for the three first rows of the table.
> Each of these threads should create a COM object
> developed using the same Delphi 5 Enterprise.
> These COM objects would then connect to the
> database using ADOConnection and ADOQuery and
> retrieve information to generate a QuickReport
> saved to a certain subdirectory.
> If only one thread is run, it works fine. But
> if the three threads them are created almost at
> the same time, I get an error for one of them (if
> it helps, the error is "The exception unknown
> software exception (0x0eedfade) occured in the
> application at location 0x77f1d479"). The error
> can be raised by any of the three COM Objects
> created, so it looks like it is a problem with
> concurrency or something...
> I tried to debug the MTS COM Objects that were
> created and found out that the error is raised
> when the COM object is trying to connect to the
> database.
> The error occurs either if I use a connection
> string or a UDL file.
> I tried CoInitializeEx(nil, COINIT_MULTITHREADED)
> in several places but it also didn't work.
> Any help will be appreciated!

> Thank you,
> Thiago

Other Threads