title: error Incorrect syntax near
body: <p>I had Registration form and I had in this form text box for username ,and when I test the web form I added this user in text box user name (Kaz'em) and I had this error</p>
  
  <p>(Incorrect syntax near 'em'.
  Unclosed quotation mark after the character string ''.)</p>
  
  <pre><code>public bool RegisteredUser()
  {
      bool Return = false;
      SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ElarabyGroup"].ConnectionString);
      SqlCommand cmd = new SqlCommand("Select Count(UserName) From [Registeration] Where [Registeration].UserName = '" + RegisteredUserName + "'", con);
      con.Open();
      if (int.Parse(cmd.ExecuteScalar().ToString()) &gt; 0)
          Return = true;
      con.Close();
      return Return;
  }
  </code></pre>