登陆代码的问题
string str = "select uid,pwd from test where uname='" + TextBox1.Text + "'";SqlConnection con = new SqlConnection("server=127.0.0.1;Integrated Security=true;database=pubs;");
con.Open();
SqlCommand com = new SqlCommand(str, con);
SqlDataReader dr = com.ExecuteReader();
try
{
if (dr.Read())
{
if (dr.GetString(1) == TextBox2.Text)
{
Session["uid"] = dr["uid"].ToString();
Response.Redirect("index.aspx");
}
else
{
Response.Write("用户密码不正确!");
}
}
else
{
Response.Write("无此用户 !");
}
}
finally
{
dr.Close();
con.Close();
con.Dispose();
}
这是在登陆按钮下的事件,可是到if(dr.Read())这块,直接就跳到else(无此用户了),请问是我代码哪块写错了吗