我创建了表 user_info,其中包含 2 个用户名和密码。当我执行下面的代码时,即使我输入正确的用户名和密码,它也总是进入“else”状态。
protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
{
string v = System.Configuration.ConfigurationManager.ConnectionStrings["harish"].ConnectionString;
con = new OracleConnection(v);
con.Open();
cmd = new OracleCommand("select * from user_info where username='" + Login1.UserName.Trim() + "' and password='" + Login1.Password + "'", con);
dr = cmd.ExecuteReader();
dr.Read();
if (dr.HasRows)
{
Response.Redirect("Default2.aspx");
}
else
{
Response.Redirect("Default.aspx");
}
con.Close();
dr.Close();
}