Link to home
Start Free TrialLog in
Avatar of Hamed Zaghaghi
Hamed ZaghaghiFlag for Iran, Islamic Republic of

asked on

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
ASKER CERTIFIED SOLUTION
Avatar of zupi5
zupi5

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
Avatar of Hamed Zaghaghi

ASKER

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
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.
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.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thanks b1xml,
it means that my user name and password is correct but, my login don't have my database permission .
Avatar of arbert
arbert

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