By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,165 Members | 1,089 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,165 IT Pros & Developers. It's quick & easy.

Windows Service Login Failed when accessing SQL.

P: n/a


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
Nov 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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.

"Evan Camilleri" <ev**@holistic.com.mt.nospam> wrote in message
news:#2**************@TK2MSFTNGP12.phx.gbl...


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

Nov 21 '05 #2

P: n/a
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
"Chris Botha" <ch***********@AT.h.o.t.m.a.i.l.com> wrote in message
news:es**************@TK2MSFTNGP15.phx.gbl...
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.

"Evan Camilleri" <ev**@holistic.com.mt.nospam> wrote in message
news:#2**************@TK2MSFTNGP12.phx.gbl...


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


Nov 21 '05 #3

P: n/a
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
"Evan Camilleri" <ev**@holistic.com.mt.nospam> wrote in message
news:u6**************@TK2MSFTNGP12.phx.gbl...
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
"Chris Botha" <ch***********@AT.h.o.t.m.a.i.l.com> wrote in message
news:es**************@TK2MSFTNGP15.phx.gbl...
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.

"Evan Camilleri" <ev**@holistic.com.mt.nospam> wrote in message
news:#2**************@TK2MSFTNGP12.phx.gbl...


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



Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.