当前位置: 代码迷 >> ASP.NET >> 为什么旧数据不能登陆?解决方法
  详细解决方案

为什么旧数据不能登陆?解决方法

热度:2306   发布时间:2013-02-25 00:00:00.0
为什么旧数据不能登陆?
protected   void   Button1_Click1(object   sender,   EventArgs   e)
        {
                SqlConnection   conn   =   new   SqlConnection(ConfigurationManager.AppSettings[ "Conectionstring "]);
                SqlCommand   cmd   =   new   SqlCommand( "select   *   from   yonghu   where   name= ' "   +   TextBox1.Text   +   " ' ",   conn);
                try
                {
                        conn.Open();
                        SqlDataReader   sdr   =   cmd.ExecuteReader();
                        if   (sdr.Read())
                        {
                               
                                if(sdr[ "password "].ToString()==TextBox2.Text.ToString())
                                {
                                        conn.Close();
                                        Session[ "ID "]   =   TextBox1.Text.Trim();
                                        Response.Redirect( "~/Hello.aspx ");
                                       
                                }
                                else
                                {
                                       
                                        Response.Write( " <script   language=javascript> alert( '密码吆~! ') </script> ");
                                }
                        }
                        else
                        {
                                Response.Write( " <script   language=javascript> alert( '用户名有问题老哥! ') </script> ");
  相关解决方案