NT Service not working with ADO???

From: Todd Super Bassist (toddjasp_at_bellsouth.net)
Date: 10/11/04


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



Relevant Pages

  • Re: Bit flipping .. will this work in VB6?
    ... such as you or another programmer on the project writing ... reporting some odd behavior can send me the file they are working on, ... in the database even though they had 190gig free on the hdd. ... If you're writing a financial app though.... ...
    (microsoft.public.vb.general.discussion)
  • Re: Structuring of large application
    ... Have you thought about possibly writing the business logic & data layer in ... one application as a web service, and writing the UI in your regular web ... Again your central login database could be another web services ... > At the centre is the User login facility - everyone using the site must ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Can I programmatically IMPORT data from XML into Access?
    ... First, I know Access 2000 didn't have the ImportXML method, but I'm not sure ... Given the overhead involved in COM Interop and Automation, ... How many records can I write to a database in 5 seconds? ... you can provide more information about how you're writing to the database ...
    (microsoft.public.access.externaldata)
  • Re: Can I programmatically IMPORT data from XML into Access?
    ... >From your test results I realize that my result is quite expected (writing ... > Given the overhead involved in COM Interop and Automation, ... How many records can I write to a database in 5 seconds? ... > performance advantages from going the automation route. ...
    (microsoft.public.access.externaldata)
  • Re: general archetecture questions.
    ... > first app i'm writing will be using XML as a database of sorts, using> dataset and dataview and wrapped up in a set of classes. ... in the past i used> ".getinstance" in java to get a single instance of a class contained in a application variable to ensure i dont have 3-4> different instances hitting the database and worse now writing 3-4 different> xml files. ...
    (microsoft.public.dotnet.framework.aspnet)