为什么我输入正确的用户名和密码之后,它不能转向m_mold.aspx页面????
这个Button_Click代码始终转向customer.aspx页面,怎么改代码???
private void Button_Click(object sender, System.EventArgs e)
{
string userid=E_ID.Text;
string userpassword=E_PASSWORD.Text;OracleConnection conn=new OracleConnection("Data Source=wk;user id=wk;password=yourpassword");
string mySelectQuery = "SELECT * FROM employee where e_id='"+userid+"' and e_password='"+userpassword+"'";
OracleCommand myCommand = new OracleCommand(mySelectQuery,conn);
conn.Open();
OracleDataReader dr = myCommand.ExecuteReader(CommandBehavior.SingleRow);
if (dr.Read())
{
Response.Redirect("m_mold.aspx");
}
else
{
Response.Redirect("customer.aspx");
} dr.Close();
conn.Close();
}
这个Button_Click代码始终转向customer.aspx页面,怎么改代码???
private void Button_Click(object sender, System.EventArgs e)
{
string userid=E_ID.Text;
string userpassword=E_PASSWORD.Text;OracleConnection conn=new OracleConnection("Data Source=wk;user id=wk;password=yourpassword");
string mySelectQuery = "SELECT * FROM employee where e_id='"+userid+"' and e_password='"+userpassword+"'";
OracleCommand myCommand = new OracleCommand(mySelectQuery,conn);
conn.Open();
OracleDataReader dr = myCommand.ExecuteReader(CommandBehavior.SingleRow);
if (dr.Read())
{
Response.Redirect("m_mold.aspx");
}
else
{
Response.Redirect("customer.aspx");
} dr.Close();
conn.Close();
}
在这句:
string mySelectQuery = "SELECT * FROM employee where e_id='"+userid+"' and e_password='"+userpassword+"'";
设F9断点,F5运行,运行后F11单步执行,抓到的语句放到SQL查询分析器中,看能否筛选出记录
先用dr.FieldCount属性测试一下中有几行记录....再找问题出现在哪.????
OracleDataReader dr = myCommand.ExecuteReader(CommandBehavior.SingleRow);
换成
OracleDataReader dr = myCommand.ExecuteReader();
直接这样执行看看。