Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to connect to database with such connection string: connectionString="Data Source=;Initial Catalog=test;User ID=user;Password=password"

So, I have default SQL Server instance (MSSQLSERVER) in my server. I found it as local in Management Studio. SQL server is running in mixed mode authentication. I added new login user/password. I attached database as test. I succesfully connect to SQL server as user/password in Management Studio. But when my web application try to connect to database, SqlException 'Login failed for user' is thrown. Webb application is hosted in IIS 7 in pool with Process Model LocalService.

What's problem?


share|improve this question
up vote 0 down vote accepted

Not only do you have to add that user to the list of Allow logins for SQL, you also have to add that user into the database itself. So that's two locations... the Logins section, and on the database itself.

share|improve this answer
Yes. I forgot to add user into the database. Thanks! – greatromul Sep 21 '11 at 19:42

Depends on your web application. Generally though you can check for appropriate connection strings.

Also make sure that you allow access on the SQL server as well.

share|improve this answer
I've alredy tried that connection strings. But error was thrown too. – greatromul Sep 21 '11 at 16:19

Did you check the SQL Server error logs for clues? If the request is reaching SQL Server, it will log an error message there?

In Management Studio, drill down to Management - SQL Server Logs, and then the current one. Depending on the message, you'll be able to Google that.

share|improve this answer

Did you run SSMS from the server that SQL is installed on? If so, that's a clue as to what the problem is: local connections work but network connections don't. Have you enabled any network protocols for SQL Server?

share|improve this answer
Network connections worked too. Clue is concluded. I just forgot to add user into the database. – greatromul Sep 21 '11 at 19:44

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.