title: "Login failed for user" C# with SQLConnection
body: <p>I've been trying to connect to my database (which is on the same computer as my code) through my C# code. The problem is I keep getting the "Login failed for user " "" error... I admit that my knowledge of connecting to databases is minimal and I've tried almost all the steps in other questions! </p>
  
  <p>here's part of my code:</p>
  
  <pre><code>SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["SQLServerConnection"].ConnectionString);
          SqlCommand command = connection.CreateCommand();
          command.CommandText = @"IF EXISTS
                              (
                                SELECT *
                                FROM user 
                                WHERE EMAILADRES = @email and WACHTWOORD = @password
                              ) SELECT CAST (1 as bit) 
                              ELSE
                                SELECT CAST(0 as bit)";
          command.Parameters.AddWithValue("email", email);
          command.Parameters.AddWithValue("password", password);
  
  
          connection.Open();
          object ReturnBool = command.ExecuteScalar();
          connection.Close();
  </code></pre>
  
  <p>and this is my connection string: </p>
  
  <pre><code>&lt;add name="SQLServerConnection" connectionString="Server=localhost; Database=database1;uid=NT AUTHORITY\NETWORK SERVICE" /&gt;
  </code></pre>