More on Connection Exception with Windows Service...!

E

Evan Camilleri

I am getting a connection exception when trying to access an SQL Server
which is NOT localhost through a Windows SERVICE. Following are the
situations:


(1) DOES NOT WORK: Windows SERVICE

Windows Service
Sql Connection = Data Source=ENTERPRISE;DataBase=CRM;Integrated
Security=SSPI;
Service Log on As = HOLISTIC\evan

Exception:
TestServ raised an Exception: System.Data.SqlClient.SqlException: Cannot
open database requested in login 'CRM'. Login fails.
Login failed for user 'HOLISTIC\evan'.
at System.Data.SqlClient.ConnectionPool.GetConnection(Boolean&
isInTransaction)
at
System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnectionString
options, Boolean& isInTransaction)
at System.Data.SqlClient.SqlConnection.Open()
at TestWindowsService.TestServ.OnStart(String[] args)



(2) DOES NOT WORK: Windows SERVICE

Sql Connection = Data Source=ENTERPRISE;DataBase=CRM;Integrated
Security=False;User ID=sa;Pwd=***;Persist Security Info=False;
Service Log on As = HOLISTIC\evan

TestServ raised an Exception: System.Data.SqlClient.SqlException: Cannot
open database requested in login 'CRM'. Login fails.
Login failed for user 'sa'.
at System.Data.SqlClient.ConnectionPool.GetConnection(Boolean&
isInTransaction)
at
System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnectionString
options, Boolean& isInTransaction)
at System.Data.SqlClient.SqlConnection.Open()
at TestWindowsService.TestServ.OnStart(String[] args)


(3) The above code will work if it is executed as Windows APPLICATION or
even as Windows SERVICE if the SQL Server is localhost.
 
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