Connect to SQL Server from Service Application

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Belitski
Posts: 14
Joined: Wed 02 Aug 2006 12:52

Connect to SQL Server from Service Application

Post by Belitski » Tue 25 Sep 2007 11:36

Hello,
We are using trial version of components for Delphi 5.
Two computer configuration in the domain: Developer computer and computer with SQL Server.
We have Service application on the developer computer.
In design mode we can connect to the SQL Server by setting in object inspector Connected := True on TMSConnection component. This works fine.
Trouble begin at attempting to start Service Application. The following code hang:
repeat
try
dbMain.Connected := true;
if dbMain.Connected then
Break;
except
on E: Exception do
begin
AddToLog('Connect failed with message: ' + E.Message);
end;
end;

sleep(5000); // 5 sec
inc(vCount);
Application.ProcessMessages;
until (vCount > (12 * 15)); // 15 min

The message that comes says: "Operation aborted".
Any ideas what is wrong?
Thank you very much.
Vladimir

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Tue 25 Sep 2007 12:13

Most likely the reason of this problem is the nag screen trying to popup in your service. This problem should disappear in a registered edition of SDAC. Registered users do not report us about such problems.

Belitski
Posts: 14
Joined: Wed 02 Aug 2006 12:52

Post by Belitski » Tue 25 Sep 2007 12:31

As far as I understand, the nag screen comes when Delphi is not started. But it came only by the first attempt to start Service, afterwards I didn't see it. I thought, the component has "remembered" the first start somewhere in the registry.
However, the Service never started (never came through the first connect). Besides of that, the checkbox for the Service allowing Data exchange with desktop is checked. Why should it be the problem?

yeohray
Posts: 56
Joined: Mon 26 Mar 2007 01:25

Post by yeohray » Tue 25 Sep 2007 15:47

I am a registered SDAC user, and use SDAC in a heavily threaded Windows service application. I have never encountered any issues with SDAC when used in my service application. The problem is probably what Antaeus has stated - the nag screen has popped up, and probably does not have a parent form in which it can be displayed correctly.

I would suggest logging to a log file, in the OnServiceStart event, to check if the execution even reaches that far.

Belitski
Posts: 14
Joined: Wed 02 Aug 2006 12:52

Post by Belitski » Wed 26 Sep 2007 07:09

Thank you for answer.
Yes, it comes so far. The code in my first post is inside the
function ConnectToDatabseWhenServiceStart that is called from
the handler OnServiceStart:

procedure TMC.ServiceStart(Sender: TService; var Started: Boolean);
begin
sDatabase := System.ParamStr(1);
sTablePrefix := System.ParamStr(2);
sUsername := System.ParamStr(3);
sPassword := Decrypt(HexStrToStr(System.ParamStr(4)), cCryptKey);

LogLevel := StrToIntDef(System.ParamStr(5), 0);

sPathLogFile := System.ParamStr(6);

dmMain := TdmMain.CreateDM(Application, bVisible, sPathLogFile);

if dmMain.ConnectToDatabseWhenServiceStart then
begin
...........
Started := True;
end
else
Started := False;
end;

yeohray
Posts: 56
Joined: Mon 26 Mar 2007 01:25

Post by yeohray » Wed 26 Sep 2007 09:13

Guess it's the nag screen then. If you want to, you can send me your code (assuming it's just a small test app), and I can compile it for you using the registered version of SDAC 4.1, so that you can determine if its really an issue with the nag screen, assuming it's ok with the CoreLab people. BTW, I use Delphi 7.

Belitski
Posts: 14
Joined: Wed 02 Aug 2006 12:52

Post by Belitski » Wed 26 Sep 2007 10:28

Thank you very much for suggestion. The project is too big to test it this way. I hope you are right and I'll wait before we get the licence.

Post Reply