读书人

问大家一个关于登陆的有关问题那

发布时间: 2012-02-06 15:52:45 作者: rapoo

问大家一个关于登陆的问题那。
private void wuzhonghao(string username, string pwd)
{
try
{
SqlConnection con = xzyywuliu.DB.createCon();
con.Open();
SqlCommand com = new SqlCommand( "select userName,userPwd,IDCard from xzcx_login where userName= ' " + username + " ' and userPwd= ' " + pwd + " ' ", con);
SqlDataReader reader = com.ExecuteReader();
if (!reader.HasRows)
{
this.Label1.Text = "用户名错误 ";
}
else
{
while (reader.Read())
{
if (pwd != reader.GetString(1))
{
this.Label1.Text = "密码错误 ";
}
else
{
this.Panel2.Visible = true;
this.Panel1.Visible = false;
Session[ "user "] = reader[ "userName "];


Session[ "ID "] = reader[ "IDCard "];

}
}
}
if (con != null)
{
con.Close();
}
}
catch
{

}

}
为什么上面代码中,我把用户输入的是正确密码输入的是错的,这样就会提示密码错误 可是他不是提示密码错误而是提示用户错误这是为什么那

[解决办法]
楼上的正解!

读书人网 >C#

热点推荐