I have developed the windows service & in windows service used the SQL server database .
when i will start the computer my windows service get started but it will not connect to the SQL server .it display the following message
"Cannot open user default database. Login failed.Login failed for user 'NT AUTHORITY\SYSTEM'."
I want to start my service when my computer starting.
how to establish the connection to SQL server database from windows service when starting the computer ?
According to the error message, you please try to follow the steps below to narrow down this issue:
First, make sure that the login 'NT AUTHORITY\SYSTEM' is existing under Security/Logins Node in the target instance on the management studio. If you cannot find it, please add the login by the following syntax:
sp_grantlogin ' NT AUTHORITY\SYSTEM '
Third, go to 'Security->Logins' in Management Studio, open the properties window of ' NT AUTHORITY\SYSTEM ' login, at the 'User Mapping' tab, map the appropriate database and select the required database role for each database.