[Fix] - ERROR Cannot open database requested by the login.

Wikitechy | 2423 Views | sql server | 08 Jun 2016

 

Error : 

  • error: Cannot open database requested by the login. The login failed. Login failed for user ‘NT AUTHORITY\NETWORK SERVICE’.

Scenario :

  • This error occurs when the application is configured with IIS, and IIS contact SQL Server to login with credentials that has no proper permissions. The error can also occur during replication or mirroring.

Fix 1 :

  • Use SQL server authentication mode with the “NT AUTHORITY\NETWORK SERVICE” user that has “sysadmin”, “public” server roles.

has a user mapping with the intended DB along with “db_owner” role as follows:



Fix 2 :

  • When there is a LAN connection between the server and the client, use the below connection string.
"Data Source=[Server_name\User_name]; Initial Catalog=[DB_name]; Integrated Security=True; Connect Timeout=30; User Instance=True"
(or)
"Data Source=[Server_name\User_name\SQLExpress]; Initial Catalog=[DB_name]; Integrated Security=True;Connect Timeout=30;User Instance=True"

Instead of Server_name the IP Address can be used.

Applies to sqlserver version : 

  • SQL Server 1.1 (16 bit)
  • SQL Server 4.2A (16 bit)
  • SQL Server 4.2B (16 bit)
  • SQL Server 4.21a
  • SQL Server 6.0
  • SQL Server 6.5
  • SQL Server 7.0
  • SQL Server 7.0 OLAP Tools
  • SQL Server 2000
  • SQL Server 2000 64-bit Edition
  • SQL Server 2005
  • SQL Server 2008
  • Azure SQL DB
  • SQL Server 2008 R2
  • SQL Server 2012
  • SQL Server 2014
  • SQL Server 2016

Related Error Tags:

  • c# - Cannot open database "" requested by the login. The login failed
  • LocalDB cannot open database requested by login. Login failed
  • Cannot open database '…' requested by the login. The login failed
  • asp.net - Login failed for user NT AUTHORITY\NETWORK SERVICE.
  • SQL Server Login error: Login failed for user NT AUTHORITY\SYSTEM.
  • FIX : ERROR : Cannot open database requested by the login.
  • Cannot open database requested by the login. The login failed.
  • Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.
  • cannot open database requested by the login the login failed sql server 2008.




Workshop

Bug Bounty
IOT Hackathon
Webinar

Join our Community

Advertise