title: C# Login page. SQL Server " sda.Fill(dt); " ERROR
body: <p>I was watching <a href="https://www.youtube.com/watch?v=tcmmCcMs8yU" rel="nofollow noreferrer">this video</a>. It basically teaches me how to create my own login page using SQL Server.</p>
  <p>So after following exactly what he did, when I click the submit button I have an error highlighting <code>sda.Fill(dt);</code>. I am pretty new to SQL Server, please advise!</p>
  <p>My code:</p>
  <pre><code>SqlConnection con = new SqlConnection(@&quot;Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\Glenntdy\Documents\GlennTeoDB.mdf;Integrated Security=True;Connect Timeout=30&quot;);        
  
  SqlDataAdapter sda = new SqlDataAdapter(&quot;Select Count(*) From Table where Username='&quot;+txtName.Text + &quot;' and Password = '&quot; +txtPassword.Text + &quot;'&quot;,con);
  
  DataTable dt = new DataTable();
  
  sda.Fill(dt);
  
  if (dt.Rows[0][0].ToString() == &quot;1&quot;)
  {
      this.Hide();
  
      Main ss = new Main();
      ss.Show();
  }
  else
  {
      MessageBox.Show(&quot;Please double check your Username and password&quot;);
  }
  </code></pre>
  <p>Picture of error:</p>
  <p><a href="https://i.stack.imgur.com/cbgHS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cbgHS.png" alt="enter image description here" /></a></p>