Cannot open database requested in login 'user'

Posted on 2005-04-30
Medium Priority
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:Hamed Zaghaghi

Accepted Solution

zupi5 earned 1000 total points
ID: 13900313
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

ID: 13900915
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


Author Comment

by:Hamed Zaghaghi
ID: 13901008
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
Free recovery tool for Microsoft Active Directory

Veeam Explorer for Microsoft Active Directory provides fast and reliable object-level recovery for Active Directory from a single-pass, agentless backup or storage snapshot — without the need to restore an entire virtual machine or use third-party tools.

LVL 23

Expert Comment

ID: 13901027
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.

Author Comment

by:Hamed Zaghaghi
ID: 13901053
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

b1xml2 earned 1000 total points
ID: 13901058
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.

Author Comment

by:Hamed Zaghaghi
ID: 13901070
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

ID: 13901360
"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....

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Microsoft Access has a limit of 255 columns in a single table; SQL Server allows tables with over 255 columns, but reading that data is not necessarily simple.  The final solution for this task involved creating a custom text parser and then reading…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Suggested Courses

809 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