string UpdateStr = "update userTab set userpsw = '" + tbPsw.Text.Trim() + "' where userid =‘" + UserID + "’";你原来的这个语句userid添加上两个单引号试试。看上面的语句

解决方案 »

  1.   

    UpdateStr 调试,监视这个变量,将变更值到SQL上执行看看
      

  2.   


                SqlConnection conn = new SqlConnection(ConfigurationManager.AppSettings["mysql"]);
                conn.Open();
     
                string UpdateStr = string.Format("update userTab set userpsw ='{0}' where userid='{1}'", tbPsw.Text.Trim(),UserID);
                SqlCommand cmd = new SqlCommand(UpdateStr, conn);  
                cmd.ExecuteNonQuery(); 
                conn.Close();            Response.Write(" <script>alert('你的密码修改成功!') </script>"); 
      

  3.   

    如果是System.Data.SqlClient.Exception,那就检查下sql语句
      

  4.   

    再调试下UserID = Session["U_userid"].ToString(); 看看UserID有没有值.
      

  5.   

    放个断点调试
    把sql语句放到查询分析器中去执行
    看对不对
      

  6.   

    string UpdateStr = "update userTab set userpsw = '" + tbPsw.Text.Trim() + "' where userid = '" + UserID + "'";