0

I am trying to connect my window service to my local db. In my OnStart() method inside Service.cs class, i am getting this error..

The underlying provider failed on Open.System.Data.SqlClient.SqlException 
(0x80131904): Cannot open database "EduFameProjectDB18" requested by the login. 
The login failed.
Login failed for user 'NT AUTHORITY\SYSTEM'.

2 Answers 2

2

You are trying to use the SYSTEM account in order to access your database. This is due to the fact that you are using integrated authentication in SQL Server and running the Windows Service under the SYSTEM account.

In order to solve this you have to provide a different credential on you windows service in order for it to open the connection properly. Make sure that the same windows user is present in the logins of SQL Server for your DB, and that it has sufficient rights to access your tables.

As an alternative you can use sql authentication, by creating a SQL Login and providing the credentials in your connection string.

Sign up to request clarification or add additional context in comments.

Comments

1
  1. Connect on Sql Server Management Studio.
  2. Now go Security -> NT AUTHORITY\SYSTEM Right Click -> Properties
  3. Click -> Server Roles
  4. Check public, sysadmin
  5. Click Ok

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.