CAUSE : This problem occurs because login that you used to access database does not have sufficient permissions.
You need to grant permission to the user to access database and/or to execute stored procedure.
How to grant reader/writer access to SQL database:
- Log on to SQL Server Management Studio by going Start >> All Programs >> Microsoft SQL Server>>> SQL Management Studio. and suppl user credentials & click OK.
- In Object Explorer, expand Secuirty, expand Logins, for which you are getting the Error and then expand Security. Make sure the Login exists else add that user by right click and add and then
- Right-click Login, and then click Properties for the USER NAME / LOGIN NAME for which you are getting the Error “Cannot open database requested by the login. The login failed”, SQL Server Error 4060
- In newly opened screen of Login Properties, go to the “User Mapping” tab. Then, on the “User Mapping” tab, select the desired database – especially the database for which this error message is displayed. On the lower screen, check the role db_owner. Click OK.
This should fix this error but consider this security recommendation
Recommendation: – Assigning a a DBO privileges to NETWORK SERVICE is security violation as mostly all security standard. Change the application / Service startup account to to dedicated Service account and then give these privileges to dedicated service / application account.
The Similar error has different interfaces. for example, In SQL Server 2012, this get the following Error Message, when you try to access a database, where user don’t have permission for specified database.
The database CRM is not accessible. (ObjectExplorer)
OR this error, when you access the same from Query Window
Msg 916, Level 14, State 1, Line 1
The server principal “hyperion” is not able to access the database “CRM” under the current security context.
OR when you try to access from front End / Application
Cannot open database requested by the login. The login failed. Login failed for user ‘NT AUTHORITY\NETWORK SERVICE’
The same solution applies to all these errors.