Login failed in Service Application
Posted: Wed 30 Aug 2006 16:51
I am having trouble with a Service application trying to login to a server
When I call DoConnect I get an errorcode 18452 and message
Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection.
The code which is causing the problem is as follows
procedure TMyThread.DoConnect(sender:tobject);
var
i:integer;
begin
i := CoInitializeEx(nil, COINIT_APARTMENTTHREADED);
if i S_OK then
logerror('err - ' + IntToStr(i))
else
begin
try
try
logerror('try to connect');
logerror(msconnection1.ConnectString);
msconnection1.connect;
logerror('connected');
upload;
except
end;
finally
couninitialize;
end;
end;
end;
constructor TMyThread.create;
begin
inherited create(true);
msconnection1 := tmsconnection.Create(nil);
msconnection1.Authentication := auserver;
msconnection1.Server := 'JOHN-LAPTOP';
msconnection1.Database := 'Impact';
msconnection1.Username := 'sa';
msconnection1.Password := 'password';
msconnection1.LoginPrompt := true;
msquery1 := tmsquery.Create(nil);
msquery1.Connection := msconnection1;
end;
I know the parameters are all OK as if I drop a TMSConnection component on the service app and set its connetced property to true it connects.
The ConnectString logged is
Provider=SQLOLEDB.1;User ID=sa;Password=password;Data Source=JOHN-LAPTOP;Initial Catalog=Impact;Persist Security Info=True
which also works fine if I paste it into a TMSConnection on a form.
Any ideas what going on?
John
When I call DoConnect I get an errorcode 18452 and message
Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection.
The code which is causing the problem is as follows
procedure TMyThread.DoConnect(sender:tobject);
var
i:integer;
begin
i := CoInitializeEx(nil, COINIT_APARTMENTTHREADED);
if i S_OK then
logerror('err - ' + IntToStr(i))
else
begin
try
try
logerror('try to connect');
logerror(msconnection1.ConnectString);
msconnection1.connect;
logerror('connected');
upload;
except
end;
finally
couninitialize;
end;
end;
end;
constructor TMyThread.create;
begin
inherited create(true);
msconnection1 := tmsconnection.Create(nil);
msconnection1.Authentication := auserver;
msconnection1.Server := 'JOHN-LAPTOP';
msconnection1.Database := 'Impact';
msconnection1.Username := 'sa';
msconnection1.Password := 'password';
msconnection1.LoginPrompt := true;
msquery1 := tmsquery.Create(nil);
msquery1.Connection := msconnection1;
end;
I know the parameters are all OK as if I drop a TMSConnection component on the service app and set its connetced property to true it connects.
The ConnectString logged is
Provider=SQLOLEDB.1;User ID=sa;Password=password;Data Source=JOHN-LAPTOP;Initial Catalog=Impact;Persist Security Info=True
which also works fine if I paste it into a TMSConnection on a form.
Any ideas what going on?
John