Service Application SQL Connection Login Error

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
hmelihkara
Posts: 21
Joined: Fri 09 Nov 2007 23:29

Service Application SQL Connection Login Error

Post by hmelihkara » Mon 01 Nov 2010 17:32

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...

AndreyZ

Post by AndreyZ » Tue 02 Nov 2010 14:46

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.

hmelihkara
Posts: 21
Joined: Fri 09 Nov 2007 23:29

Post by hmelihkara » Wed 03 Nov 2010 10:03

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.

AndreyZ

Post by AndreyZ » Wed 03 Nov 2010 14:59

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;

Post Reply