I am trying to connect to SQL server through an asp.net page and I am getting this error:
Cannot open database “dbname” requested by the login. The login failed.
Login failed for user ‘username’.
And when I try to login directly at SQL using the same credentials it does connect successfully. And the username and password set in the webconfig are correct.
I tried setting a new password, remove the user from the database and add it again but it doesn’t work through web only through SQL.
The
Database(orInitial Catalog) value in the connection string refers to a database (on the server) that doesn’t exits or the login has no permissions.When you connect using the SQL tools, it is picking up the default database (defined by the login) or you are sending a working value
Edit, after comment
The error says Cannot open database “dbname” requested by the login..
This means the
databasevalue in the asp.net generated connection string is wrong. Not much scope for ambiguity here