How to configure MS SQL Server 2008 R2 (login failed for user)?

7,580

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:
7,580
greatromul
Author by

greatromul

I push keys...

Updated on September 18, 2022

Comments

  • greatromul
    greatromul almost 2 years

    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.

  • greatromul
    greatromul almost 13 years
    I've alredy tried that connection strings. But error was thrown too.
  • greatromul
    greatromul almost 13 years
    Yes. I forgot to add user into the database. Thanks!
  • greatromul
    greatromul almost 13 years
    Network connections worked too. Clue is concluded. I just forgot to add user into the database.