NT Service not working with ADO???
From: Todd Super Bassist (toddjasp_at_bellsouth.net)
Date: 10/11/04
- Next message: deliMawi: "Re: Accessing A Large MS SQL Table Over ADO Components"
- Previous message: Viatcheslav V. Vassiliev: "Re: Accessing A Large MS SQL Table Over ADO Components"
- Next in thread: danny heijl: "Re: NT Service not working with ADO???"
- Reply: danny heijl: "Re: NT Service not working with ADO???"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 11 Oct 2004 09:41:14 -0400
Hey guys,
I don't remember if I've posted this problem here before, but I have
Delphi 7, and I'm writing a Windows NT Service. I seem to have a problem
accessing database functions, either writing or reading.
I am accessing an ADO database (MS SQL) using the ADO components (Query, and
Command).
This is my Execute procedure....
Procedure ExecuteService;
Var
ErrMsg : String;
Begin
Try
Begin
MainProcess;
End;
Except
On E: Exception Do
Begin
RM_FUNC.WriteTxtLog(2,'[ERROR] - Encountered a problem in
SERVICE EXECUTE!');
ErrMsg := SysErrorMessage(GetLastError);
WriteTxtLog(1,ErrMsg);
End;
End;
End;
Where you see in the procedure "MainProcess", I have a single line... I have
commented everything out so that I can narrow it down. It errors out on the
VERY first line within the MAINPROCESS procedure.
This line that it errors out on is: RM_FUNC.ReadLab(RM_GLOBAL.CurrLab);
This line merely sends to the ReadLab procedure the current lab #. What I do
then is pull a single field out. This procedure ReadLab looks like this:
Procedure ReadLab(LabNum : Integer);
Var
SQLStatement : String;
Begin
SQLStatement := ('SELECT T1.REPORT_FOLDER_PATH '
+ 'FROM LAB T1 '
+ 'WHERE (T1.ID = ' + IntToStr(LabNum) + ')');
RM_DATA.RM_DM.RM_Input.Active := False;
RM_DATA.RM_DM.RM_Input.SQL.Clear;
RM_DATA.RM_DM.RM_Input.SQL.Text := SQLStatement;
RM_DATA.RM_DM.RM_Input.Active := True;
Begin
RM_GLOBAL.LabRootPath :=
RM_DATA.RM_DM.RM_Input.FieldByName('REPORT_FOLDER_PATH').AsString;
End;
RM_DATA.RM_DM.RM_Input.Active := False;
RM_DATA.RM_DM.RM_Input.SQL.Clear;
End;
With text logging that I've been putting in, I can pinpoint the error as
occuring RIGHT at the line that says: RM_DATA.RM_DM.RM_Input.Active :=
False;
Any idea what I'm doing wrong? Am I not initializing something???
Oh yeah, if you need to see it, the procedure that calls ExecuteService is:
"ServiceExecute" and it looks like this:
(* MAIN SERVICE EXECUTE Procedure *)
Procedure TIntService.ServiceExecute(Sender: TService);
Begin
While NOT Terminated Do
Begin
ExecuteService;
Sleep(10000);
ServiceThread.ProcessRequests(False);
End;
End;
Thanks, any help you guys can give me I would REALLY REALLY appreciate. I've
written a few services before, but none that access databases. I have one
that automatically prints files that appear in a folder, one that does a
text file to text file conversion (parses a file and exports it into a
different format). But this is the frist database program that I have tried
to convert into a Service.
Also, I have a regular application where I use all these same functions (I
tried to create it as an application first before I tried to convert it to a
service) and it all works PERFECTLY. Just not when I try to convert it as a
service.
THANKS!!!!!!!!!
Todd
- Next message: deliMawi: "Re: Accessing A Large MS SQL Table Over ADO Components"
- Previous message: Viatcheslav V. Vassiliev: "Re: Accessing A Large MS SQL Table Over ADO Components"
- Next in thread: danny heijl: "Re: NT Service not working with ADO???"
- Reply: danny heijl: "Re: NT Service not working with ADO???"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|