日期:2014-05-20  浏览次数:20638 次

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