SQL Server Error Cannot Open Database Requested by the Login

Resolved SQL
CM
Community Member
February 17, 2016
2 replies
1,567 views
Reviewed by moderators

I am trying to connect to MS SQL Server database using SQL Authentication, but it fails with this error:

Cannot open database “DatabaseName” requested by the login. The login failed. rnLogin failed for user ‘NT AUTHORITY\NETWORK SERVICE’.

2 Answers
Accepted Answer
Verified by Edwin J. Hoffer, Expert · Reviewed February 2016

If you are using Windows authentication, thennCreate a SQL Server log login for NT AUTHORITY\NETWORK SERVICE on your SQL Server nornChange the connection string like this nnconnectionString=" Servere=.\SQLExpress; Database=IFItest; User ID=UserName; pwd=password"n

This error generally happens when users configured an asp. net application to IIS, and IIS tries to gain access (login) with improper permission. nnTo fix this errornn
    n
  • Open SQL Server Management Studio >> Security >> Logins (right click on the user) >> Properties n
  • nnnnnnn
  • On Login Properties window, click on User Mapping from the left pane.
  • n
  • Under Users Mapped to this login: select the database and from the lower screen (Database role membership for: Database) check db_owner role and click ok
  • nnnn