The database 'DB Name' is not accessible

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.

  • SQL Dependency on SQL Server 2008 Express
  • Optimizing CASE WHEN statement in SQL Server WHERE clause condition
  • Linq or Stored proc - Which should I choose?
  • Fetch the all the column except one
  • Go with SQL Server driver is unable to connect successfully, login fail
  • Will the SQL Server default dateformat/language affect my DateTime object toString rendering?
  • 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.

  • Using tuples in SQL “IN” clause
  • Passing carriage return to SQL SP through C#
  • tablix returns only 1 record for dataset
  • GRANT syntax for domain\user
  • How can I check whether a number is contained in comma separated list stored in a varchar column?
  • SQL: Numbering the rows returned by a SELECT statement
  • One Solution collect form web for “The database 'DB Name' is not accessible”

    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.

    MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.