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.