0

I want to connect to database with such connection string: connectionString="Data Source=111.111.111.111;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?

Thanks.

4 Answers 4

0

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.

1
  • Yes. I forgot to add user into the database. Thanks!
    – greatromul
    Sep 21, 2011 at 19:42
0

Depends on your web application. Generally though you can check http://www.connectionstrings.com/sql-server-2008 for appropriate connection strings.

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

1
  • I've alredy tried that connection strings. But error was thrown too.
    – greatromul
    Sep 21, 2011 at 16:19
0

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.

0

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?

1
  • Network connections worked too. Clue is concluded. I just forgot to add user into the database.
    – greatromul
    Sep 21, 2011 at 19:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .