Windows Service & ADO problem
- From: "Allen" <allen.NoSp@xxxxxxxxxxxxxxxxxxxx>
- Date: 15 Sep 2006 09:54:53 -0700
Hi,
I have a problem with a block of code causes corruption of the NTLDR
when the system is shut down.
I impliment the ADO code in a thread where the Execute code contains a
call to InitObjects (below) to set up the objects. The Thread execute
method has a loop that has a break statement to step out of the loop
when terminated. The FreeThreadObjects (below) is called when the
thread is terminated. The thread is implimented from a windows service
application. When the service is terminated normally the service shuts
down and no harm is caused. When the machine is gracefully shut down
(Start , Shutdown) no harm is done, however if the thread is active and
the machines power switch is held down to force the machine to shut
down then the logging I have suggests that the FreeThreadObjects code
is never called, and the OS becomes corrupted.
If anyone has any idea's what might be occuring or suggestions of
something to try to prevent this from occuring I would be most grateful
to hear from you.
Thanks,
-Allen
procedure TWorkThread.InitObjects;
begin
CoInitialize(nil);
LogMessage('CoInitialize');
ADOConnection1:= TADOConnection.Create(nil);
ADOConnection1.ConnectionString:=
'Provider=SQLOLEDB.1;Password=smartdev;Persist Security Info=True' +
';User ID=smartdev;Initial Catalog=SteinerEOVProcessing;Data Sour' +
'ce=192.168.1.80';
ADOConnection1.LoginPrompt:= False;
ADOConnection1.Provider:= 'SQLOLEDB.1';
ADOQuery1:= TADOQuery.Create(nil);
ADOCommand1:= TADOCommand.Create(nil);
ADOCommand1.Connection:= ADOConnection1;
spIns_InventoryTransactionDetail:= TADOStoredProc.Create(nil);
spIns_InventoryTransactionDetail.Connection:= ADOConnection1;
spIns_InventoryTransactionDetail.ProcedureName:=
'prc_Insert_xmlInventoryTransactionDetails;1';
spIns_ReceiptDetails:= TADOStoredProc.Create(nil);
spIns_ReceiptDetails.Connection:= ADOConnection1;
spIns_ReceiptDetails.ProcedureName:= 'prc_Insert_xmlReceiptDetails;1';
ADOStoredProc1:= TADOStoredProc.Create(nil);
ADOStoredProc1.Connection:= ADOConnection1;
ADOStoredProc:= TADOStoredProc.Create(nil);
ADOStoredProc.Connection:= ADOConnection1;
ADOStoredProc.ProcedureName:= 'prc_RegisterVoyage;1';
ADOStoredProc.Parameters.Refresh;
ADOQuery:= TADOQuery.Create(nil);
end;
procedure TWorkThread.FreeThreadObjects;
begin
if (ADOQuery1 <> nil) then
ADOQuery1.Free;
if (ADOCommand1 <> nil) then
ADOCommand1.Free;
if (ADOConnection1 <> nil) then
ADOConnection1.Free;
if (spIns_InventoryTransactionDetail <> nil) then
spIns_InventoryTransactionDetail.Free;
if (spIns_ReceiptDetails <> nil) then
spIns_ReceiptDetails.Free;
if (ADOStoredProc1 <> nil) then
ADOStoredProc1.Free;
if (ADOStoredProc <> nil) then
ADOStoredProc.Free;
if Assigned(ADOQuery) then
ADOQuery.Free;
CoUninitialize;
LogMessage('CoUninitialize');
end;
--
.
- Follow-Ups:
- Re: Windows Service & ADO problem
- From: Guillem
- Re: Windows Service & ADO problem
- Prev by Date: Re: How to copy an access table in a mdb file using ado and delphi 6 pro
- Next by Date: Re: Delphi7 / ADO - 'Origin' property of TQuery blank
- Previous by thread: How to copy an access table in a mdb file using ado and delphi 6 pro
- Next by thread: Re: Windows Service & ADO problem
- Index(es):