Vikram
Vikram

Reputation: 495

Wcf library in Windows Service

I am unable to connect from my windows service to SQL server

Exception:Service cannot be started. System.ServiceModel.FaultException`1[System.ServiceModel.ExceptionDetail]: Login failed for user 'LOBAANSOFTWARES\LBS-PC-19$'. (Fault Detail is equal to An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, whose value is: System.Data.SqlClient.SqlException: Login failed for user 'LOBAANSOFTWARES\LBS-PC-19$'. at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK) at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, SqlConnection owningObject) at System.Data.SqlClient.SqlInternalConnecti...

Is their is another service to start for resolve this solution

Upvotes: 0

Views: 1501

Answers (2)

marc_s
marc_s

Reputation: 755321

The error message is pretty clear:

Login failed for user 'LOBAANSOFTWARES\LBS-PC-19$'.

That user (the machine name of the machine your service is running on) doesn't have any permissions to log on to SQL Server.

You can either:

  • give that user rights to connect to SQL Server and the proper database(s)
  • have the service run under a different user account which has the rights to SQL Server
  • define a specific connection string in your NT service application to use a particular user to connect to SQL Server

Your connection string probably looks something like:

server=(your server name);database=YourDatabase;Integrated Security=SSPI

This attempts to connect to SQL server with the user that's running the service - by default your machine's computer account.

You can change your connection string to use a specific SQL Server user you've created instead:

server=(your server name);database=YourDatabase;User ID=YourNewUser;Pwd=Top$Secret

Upvotes: 1

TabbyCool
TabbyCool

Reputation: 2839

Have you checked the security on your database to make sure the user exists and has sufficient authority to connect? Is the Windows service using the correct password for the user account it runs as?

Upvotes: 0

Related Questions