Cannot open database requested in login 'user'

hi experts,

when i want to login to sql server database with this connection string:
Server=<server>;Database=<database>;uid=<user>;pwd=<***>;

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'.

thanks;
have a good programming day;
--hamed
LVL 9
Hamed ZaghaghiProgrammerAsked:
Who is Participating?
 
zupi5Connect With a Mentor Commented:
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.
0
 
b1xml2Commented:
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

HTH
0
 
Hamed ZaghaghiProgrammerAuthor Commented:
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
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

 
b1xml2Commented:
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.
0
 
Hamed ZaghaghiProgrammerAuthor Commented:
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.
0
 
b1xml2Connect With a Mentor Commented:
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.
0
 
Hamed ZaghaghiProgrammerAuthor Commented:
thanks b1xml,
it means that my user name and password is correct but, my login don't have my database permission .
0
 
arbertCommented:
"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....
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.