con.Open();
                        string uuser = "Update users set userpwd='"+txtnewpwdtwo.Text+"' where username='" + txtuusername.Text + "'and userpwd='" + txtuuserpwd.Text + "'and usercid = '"+txtuusercid.Text+"'";
                        SqlCommand cmd = new SqlCommand(uuser, con);
                        cmd.ExecuteNonQuery();
                        Label1.Text = "<script>alert('修改密码成功!')</script>";看是没问题但是我点击按钮修改密码的时候发先第二个条件'and usercid = '"+txtuusercid.Text+"'";和数据库不匹配也会会弹出说修改密码成功,还好数据库是没改的。这咋办。麻烦老大门清楚点告诉我

解决方案 »

  1.   

    你可以设断点 看看这个语句是什么 在拿到sql中执行看看 有结果吗
      

  2.   

    int i=cmd.ExecuteNonQuery();如果i=0 说明不匹配.
      

  3.   

    从上往下执行,当然会弹出了,Label1.Text = " <script>alert('修改密码成功!') </script>"; 
    应该写在条件里面  if(修改成功){ Label1.Text = " <script>alert('修改密码成功!') </script>"; 
      }
      

  4.   

    因为你Label1.Text = " <script>alert('修改密码成功!') </script>"; 这句话了
    连判断都没有一定会执行的
      

  5.   

    cmd.ExecuteNonQuery(); 
    Label1.Text = " <script>alert('修改密码成功!') </script>"; cmd.ExecuteNonQuery(); 执行后你应该判断一下是否有影响的行数..
    如果有再提示..
    要不就会出现你现在的结果..
      

  6.   


                          string uuser = "Update users set userpwd='"+txtnewpwdtwo.Text+"' where username='" + txtuusername.Text + "'and userpwd='" + txtuuserpwd.Text + "'and usercid = '"+txtuusercid.Text+"'"; 
                            SqlCommand cmd = new SqlCommand(uuser, con); 
                           int val= cmd.ExecuteNonQuery(); 
                           if(val>0)
                            Label1.Text = " <script>alert('修改密码成功!') </script>";
                           else
                              Label1.Text = " <script>alert('error!') </script>";
      

  7.   

     Label1.Text = " <script>alert('修改密码成功!') 前加条判断。
      

  8.   


    if(cmd.ExecuteNonQuery()>0)
    {
    //执行成功
    }
      

  9.   

    貌似 ,和and之间没有空格啊。
      

  10.   


    con.Open();
                             string uuser = "Update users set userpwd='"+txtnewpwdtwo.Text+"' where username='" + txtuusername.Text + "'and userpwd='" + txtuuserpwd.Text + "'and usercid = '"+txtuusercid.Text+"'";
                             SqlCommand cmd = new SqlCommand(uuser, con);
                             int i = cmd.ExecuteNonQuery();
    if(判断i){
                             Label1.Text = " <script>alert('修改密码成功!') </script>";}
    else{}
      

  11.   

     SQL 有问题 太复杂了 你可以 先查询出来在页面.CS写判断啊,.
    <script>alert('修改密码成功!') </script>  括号后面有个分号
      

  12.   


    var iReslut = cmd.ExecuteNonQuery();
    if(iReslut == 1)Label1.Text = " <script>alert('修改密码成功!') </script>"; 
      

  13.   

    加判断,int i= cmd.ExecuteNonQuery();if(i>0){...}else{...} 
      

  14.   

    你只是执行了语句,并没有判断执行结果,所以这是你代码缺少判断逻辑的问题,不是SQL的问题。
      

  15.   

    如果usercid 是整型的号,就不需要单引号了
     string uuser = "Update users set userpwd='"+txtnewpwdtwo.Text+"' where username='" + txtuusername.Text + "'and userpwd='" + txtuuserpwd.Text + "'and usercid = "+txtuusercid.Text;