我有注册表单,我在这个表单的用户名文本框中,当我测试网页表单时,我在文本框用户名(Kaz'em)中添加了这个用户,我有这个错误
('em'附近的语法不正确.字符串''后面的未闭合引号.)
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()) > 0)
Return = true;
con.Close();
return Return;
}
Run Code Online (Sandbox Code Playgroud)