首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

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

2012-02-06 
问大家一个关于登陆的问题那。privatevoidwuzhonghao(stringusername,stringpwd){try{SqlConnectionconxzy

问大家一个关于登陆的问题那。
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
                {  
               
                }

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

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

热点排行