title: asp.net Login Website from database
body: <p>I have a website with a login, from a database.</p>
  
  <p>This is my code :</p>
  
  <pre><code>        protected void SignIn_Click(object sender, EventArgs e)
          {
              SqlConnection con = new SqlConnection("Data Source=MICROSOF-58B8A5\\SQL_SERVER_R2;Initial Catalog=Movie;Integrated Security=True");
              con.Open();
  
              string cmdStr = "select count(*) from Users";
  
              cmdStr += "where Username='" + UsernameSignIn.Text + "'";
              cmdStr+= "AND Password='"+PasswordSignIn.Text+"'";
  
              SqlCommand cmd = new SqlCommand(cmdStr, con);
  
              int i = Convert.ToInt16(cmd.ExecuteScalar());
  
              if (i == 0)
              {
                  ErrorSignIn.Text = "Sorry, Wrong Username or Password";
              }
              else
              {
                  Response.Redirect("HomeAfter.aspx");
              }
          }
  </code></pre>
  
  <p>for some reason, I run into an error :</p>
  
  <blockquote>
    <p>Incorrect syntax near '-'</p>
  </blockquote>
  
  <p>.
  (for this line : <code>int i = Convert.ToInt16(cmd.ExecuteScalar());</code> )</p>
  
  <p>Thanks,</p>