菜鸟求救,大大们帮偶看看这代码吧,究竟哪儿错了?跪谢了~
这是用户登陆身份验证,代码写在点击事件里了
aa表的两个字段a,b分别代表用户id和密码,但我用户密码全输入正确时,text依然提醒我密码错误,为什么啊?这东西烦了我两天了,偶是菜鸟,大大们救救偶吧,跪谢了~~
我也做了些调试,比如ds.Tables["aa"].Rows[0][1].ToString()==Lable5.Text,结果显示的是正确的密码,但是Label4.Text依然提示我密码错误~~
private void Button1_Click(object sender, System.EventArgs e)
{
try
{
SqlConnection con=new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["ccc"]);
SqlDataAdapter ada=new SqlDataAdapter("select * from aa where a='"+Request.Form["TextBox1"]+"'",con);
DataSet ds=new DataSet();
ada.Fill(ds,"aa");
Label5.Text=ds.Tables["aa"].Rows[0][1].ToString();
if(ds.Tables["aa"].Rows.Count!=0)
{
if(ds.Tables["aa"].Rows[0][1].ToString()==TextBox2.text)
{
Label4.Text="密码正确";
}
else
{
Label4.Text="密码错误";
}
}
else
{
Label3.Text="无此用户名";
}
}
catch(Exception d)
{}
}