登录页面无法登录到相应页面
public partial class _Default : System.Web.UI.Page {
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
string str = ConfigurationSettings.AppSettings["dsn"];
SqlConnection cn = new SqlConnection(str);
cn.Open();
string mysql = "select * from admin where aid='" + tbx_aid.Text + " 'and apassword ='" + tbx_apassword.Text + "'";
SqlCommand cm =new SqlCommand(mysql,cn);
SqlDataReader ur =cm.ExecuteReader();
if (ur.Read())
{
label4.Text = "";
Session["aid"]= ur["aid"];
Session["aname"]= ur ["aname"];
Session["apower"]= ur ["apower"];
Session["adep"]= ur ["adep"];
if (Session["apower"]=="1")
{
Response.Redirect("admin.aspx");
}
if (Session["apower"]=="2")
{
Response.Redirect("kqmanage.aspx");
}
if (Session["apower"]=="3")
{
Response.Redirect("lr3.aspx");
}
label4.Text = "用户名/密码不正确,请重新输入";
} cn.Close();
}
}
我运行了一下没有报错,可就是输入用户名和密码以后无法登录相应的页面