Windows Service Login Failed when accessing SQL.

E

Evan Camilleri

I have a problem for a Windows Service to login on an SQL server (different
machine) - neither Windows Authentication nor SQL Authentication worked.
LOGIN FAILED FOR USER sa (for example).

If SQL Server is on the same PC of the Windows Service the connection works
OK.

The same code works in a Windows Form using same user and authentication
methods to the SQL Server on a different machine.

Thanks for any help!

Evan Camilleri
 
C

Chris Botha

The SQL Auth. should work if the connect string is correct. Also check that
the Authentication for the target SQL Server is set to "SQL Server and
Windows" and not "Windows only".
Windows Auth. will give you a problem if the service runs under the Local
System account (local for the computer with the service installed), it is
unknown to the remote SQL Server. To get this to work, right click on the
service and change the Log On account of the service to be some network
account that has rights on the local computer as well as the SQL Server.
 
E

Evan Camilleri

I tried already using 'Log On Account' and still in vain!
The same code does NOT give problems if used in Windows Forms.
I even tried SQL Authentication and it works in Windows Forms but NOT in
Windows Service.

Evan Camilleri
 
E

Evan Camilleri

Solved

The problem was stiupid. The database is named CRM on the localhost and
CRM2003 on the server

:(

Maybe as message Database not found would have been more ideal instead of
login fails!


Thanks anyway.

Evan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top