我想从电子邮件和密码的数据库中获取记录,我搜索并浪费了很多时间,但我没有得到任何东西。
[WebMethod]
public bool CheckLogin(string Email, string Password)
{
return getEmail(Email, Password);
}
public bool getEmail(String Email, String Password)
{
SqlConnection NewCon;
NewCon = Class1.GetConnection();
NewCon.Open();
bool check = false;
string pa;
SqlCommand CheckCmd = new SqlCommand("SELECT * from RegisterUsers WHERE Email ='" + Email + "' and Password='" + Password + "'", NewCon);
CheckCmd.CommandType = CommandType.Text;
CheckCmd.Parameters.Add("@Email", SqlDbType.NVarChar).Value = Email;
SqlDataReader sdr = CheckCmd.ExecuteReader();
while (sdr.Read())
{
pa = sdr.GetString(8); // for Password column
if (pa == Password)
{
check = true;
}
break;
}
NewCon.Close();
return check;
}