我尝试检查用户是否存在。我尝试:
public static bool GetUser(string tblName, string UserName,string Password,string Usertype)
{
try
{
using (SqlConnection con = Connection.GetConnection())
{
using (SqlCommand cmd = con.CreateCommand())
{
cmd.CommandText = "select count(UserName) from " + tblName + " where Password=" + Password + " and usertype=" + Usertype + " and username="+ UserName + "";
object obj = cmd.ExecuteScalar();
if (obj != null)
return true;
return false;
}
}
}
catch (Exception ex)
{
throw ex;
}
}
当我调用此方法时,出现以下错误。
连接已成功建立,我这样调用此方法。
bool Check = UserLogin.GetUser("OnlineCertificationLogin", "admin", "admin", "Admin");
我的表结构是
找不到我的错误。谢谢。