我有一个登录页面,我在其中编写了代码来登录管理部分,但它不起作用我不知道这是什么问题,代码是正确的,但仍然获得未经授权的访问。帮帮我
string str = ConfigurationManager.ConnectionStrings["ottscon"].ConnectionString;
using (SqlConnection con = new SqlConnection(str))
{
SqlCommand cmd = new SqlCommand("Select UserName,Password from login where UserName=@userid and Password=@passid", con);
con.Open();
cmd.Parameters.AddWithValue("@userid", TextBox1.ToString());
cmd.Parameters.AddWithValue("@passid", TextBox2.ToString());
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds= new DataSet();
da.Fill(ds);
if (ds.Tables[0].Rows.Count>0)
{
Session["login"] = TextBox1.Text;
Response.Redirect("admintrator123/Default.aspx");
}
else
{
Label1.Text = "Unauthorized Access";
Label1.ForeColor = System.Drawing.Color.Red;
}
}