Reputation: 25
I am getting following error each time I tried to select database. The database 'DB Name' is not accessible. (Microsoft.SqlServer.Express.ObjectExplorer)
Note: My OS is Win Vista.
When I tried to open SQL Mgmt Studio as Run as administrator than I can able to access database properly.
Any idea why it is giving error.
I am also getting following error when my asp.net application is trying to access database.
Cannot open database "DBName" requested by the login. The login failed. Login failed for user 'PCName\abcd'.
I am not very good with SQL Server, please let me know how to create user and grant them permission in case that is what causing the problem.
Thanks.
Upvotes: 2
Views: 11691
Reputation: 29041
This is a permissions issue. When you run SSMS as administrator, you have access to everything. Your ASP.NET app is (and should be) connecting with a different user account, and does not have that access.
Create a new login in SQL server for your application, with its own username and password.
Add that login to your database DbName (under the \databases\DbName\security in SSMS) and give it the correct permissions.
Upvotes: 5