While working with a combination of ASP.Net/Visual Studio/IIS/SQL Server, etc, you may occasionally come across something like:
Cannot
open database "AdventureWorks" requested by the login. The login failed. Login failed for user 'My-PC\vic'.
Where 'My-PC' is the PC or Workstation name and 'vic' is a valid user login name on the PC.
This error usually occurs when an asp.net application is configured to use IIS, and the application is trying to gain access (or login) to a SQL Server database that has not been configured with sufficient permissions for the current user of that application.
Potential fix as follows:
Under the 'Logins' node of the 'Security' node in SSMS, right-click on the user and select Properties.
Then on the Login properties dialogue click on 'User Mapping' in the 'Select a page' left window, tick the database that has the login issue in the 'Users mapped to this login:' in the right window, and the in the bottom window under 'Database role membership for: [AdventureWorks]', make sure 'db_owner' is ticked.
In most cases this should help resolve the issue.
And if this doesn't solve the problem, what should I try next?
ReplyDeleteThis didn't seem to solve the issue for me either...
DeleteIt is useful to learn how to set and reset a error.Thank you author for posting this kind of error.
ReplyDeletehttp://www.wikitechy.com/fix-error/sql-server-error-cannot-open-database-requested-by-the-login
Both are really good.
Cheers,
Venkat