我尝试检查用户存在或not.I尝试:
的SQLException是由用户代码未处理的在C#
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");
我的表结构
无法找到我的mistake.Thanks。