Cannot open database requested in login 'user'

Posted on 2005-04-30
Last Modified: 2008-02-01
hi experts,

when i want to login to sql server database with this connection string:

i get the following error:
Cannot open database requested in login 'user'. Login fails. Login failed for user 'user'.

note that if i enter incorrect data for username or password i get this diferent error:
Login failed for user 'user'.

have a good programming day;
Question by:zaghaghi
    LVL 6

    Accepted Solution

    what database are you using, if you are using MS sql, check if the user has access to the database, not only logon persmission. Looks like the user is not allowed to use the database. You can set users database access from sql login properties/Database access tab, check the databeses the user must have access to.
    LVL 23

    Expert Comment

    It appears that your Server may be using Windows Authentication
    1. Right click on the server in Enterprise Manager
    2. Click on "Properties" Menu Item
    3. Click on "Security" Tab
    4. Check the "SQL Server and Windows" under Authentication.
    5. Click on the "OK" button.
    6. Re-start MSSQL Server.

    If it is a database access permissions problem, you'd have to ensure that the SQL Account used has access to the database concerned.
    1. Expand the database you are seeking access to.
    2. Click on the "User" item located on the left pane.
    3. The dialog window "Database User Properties - New User" pops up.
    4. Select the appropriate login, type the user name if not the same.
    5. Check the appropriate roles.
    6. Click on the "OK" button.
    7. You do NOT need to re-start MSSQL Server

    LVL 9

    Author Comment

    hi b1xml2, my server don't use Windows Authentication,

    I have a .com domain, and my host admin saied that , my user name and password is worked correctly, but my application raise this sql exception.

    thanks, but any other help
    LVL 23

    Expert Comment

    well then if it is a hosted site, you'd have to liase with them. You do not have full control on SQL Server.

    If Mixed Security is set up then obviously, it is an database access permissions problem. To test this out, can you log into your SQL Server hosted by your ISP via Query Analyzer with the user name and password. This is a quick way to see if the account has access permissions to the db.
    LVL 9

    Author Comment

    sql server of my site, dose'nt have a valid IP, so i can't check it with query analyzer, or other sql server tools,
    i make a simple web application thet test the connection, and that application show the above error.
    LVL 23

    Assisted Solution

    then you are working blindly. You cannot then say that you know the user account has the correct access permissions. I would say insufficient access permissions to the database, or incorrect authentication mode.
    LVL 9

    Author Comment

    thanks b1xml,
    it means that my user name and password is correct but, my login don't have my database permission .
    LVL 34

    Expert Comment

    "it means that my user name and password is correct but, my login don't have my database permission ."

    Not necessarily.  I'm guessing they setup your login/password, but you don't have permissions to the  database they assigned as your "default database".

    Call your host....

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Performance is the key factor for any successful data integration project, knowing the type of transformation that you’re using is the first step on optimizing the SSIS flow performance, by utilizing the correct transformation or the design alternat…
    Introduced in Microsoft SQL Server 2005, the Copy Database Wizard ( is useful in copying databases and associated objects between SQL instances; therefore, it is a good migration and upgrade tool…
    This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
    Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now