[Fix] - SQL Server Error : Cannot open database requested by the login.
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.
Fixes are applicable to the following versions of SQL Server:
- SQL Server 7.0 OLAP Tools
- SQL Server 2000 64-bit Edition
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”