467,911 Members | 1,438 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,911 developers. It's quick & easy.

Windows Service Login Failed when accessing SQL.



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
  • viewed: 3220
Share:
3 Replies
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
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
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.

Similar topics

1 post views Thread by Al | last post: by
1 post views Thread by Ibrahim Mohamed El-Ganady | last post: by
3 posts views Thread by =?Utf-8?B?RGFuZGFuIFpoYW5n?= | last post: by
1 post views Thread by igor | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.