Page 1 of 1

Service Application SQL Connection Login Error

Posted: Mon 01 Nov 2010 17:32
by hmelihkara
Dear Entitled,
I've service application written in Delphi 2010 and using SDAC 5.
Unfortunately the service application can not start automatically when I check the application logs that I see cannot login with sa or Windows Authentication.
After connecting to the system I can start it manually.

So... How can I autostart my service application. May be have to start after some other service started. Also I added my service application's Dependencies MSSQL SERVER but nothing changes, Still can not autostart it!!!

Thanks...

Posted: Tue 02 Nov 2010 14:46
by AndreyZ
Hello,

This problem is connected with the specificity of the SQL Server work. We cannot influence that. You can try connecting to the server through ADO and check if you can connect.

Posted: Wed 03 Nov 2010 10:03
by hmelihkara
Hello,
I already know problem is not related to SDAC.
But do you know any solutions or workarounds about this problem?

Probably a timing problem is occuring, MSSQLSERVER service started, after that MyService application started and try to connect to specific database. I put it to dependencies but still not success. If I login to system via remote desktop and start MyService manually no problem occurs.

Can you offer me any solutions? Cause starting the service everytime if server-restarst or gets unexpected server-shutdowns are very painfull.

Thanks.

PS: I try to give same credentials (Administrator) manually to both MSSQL Service and MyService, but still MyService giving same error on trying to auto-startup.

Posted: Wed 03 Nov 2010 14:59
by AndreyZ
You can try using the following code:

Code: Select all

procedure TMyServ.ServiceExecute(Sender: TService);
begin
  CoInitializeEx(NIL, 0);

  while not MSConnection.Connected do
  begin
    try
      MSConnection.Connect;
    except
    end;
    if not MSConnection.Connected then
      sleep(1000);
  end;
  // successfull connection

  CoUnInitialize;
end;