protected void btnupdate_Click(object sender, EventArgs e)
    {
        SqlConnection con = new SqlConnection(connectionString);        if (txtjnamei.Text != "" && txtjagei.Text != "" && ddjsexi.Text != "" && ddjrecordi.Text != "" && ddjworkyeari.Text != "" && txtjphonei.Text != "" && txtjemaili.Text != "" && ddjobsi.Text != "")
        {
            if (HttpContext.Current.Session["CheckCode"].ToString().Equals(this.txtjverifyi.Text.ToString().Trim()))
            {
                try
                {
                    con.Open();
                    string updatesql = "Update jobperson set jusername='" + txtjusernamei.Text + "',jname='" + txtjnamei.Text + "',jage='" + txtjagei.Text + "',jsex='" + ddjsexi.Text + "',jworkyear='" + ddjworkyeari.Text + "',jemail='" + txtjemaili.Text + "',jrecord='" + ddjrecordi.Text + "',jphone='" + txtjphonei.Text + "',jobs='" + ddjobsi.Text + "',jdetailed='" + txtjdetailedi.Text + "' where jID='" + Label4i.Text + "'";
                    SqlCommand cmd = new SqlCommand(updatesql, con);
                    int i = cmd.ExecuteNonQuery();
                    con.Close();
                if (i != 1)
                {
                    Label5i.Text = "<script>alert('修改成功!')</script>";
                }
                else
                {
                    Label5i.Text = "<script>alert('失败!')</script>";
                }
                                    }
                catch (SqlException ex)
                {
                    throw ex;
                }
                finally
                {
                    con.Close();
                }
                
            }
            else
            {
                Label5i.Text = "<script>alert('验证码不正确')</script>";
            }
        }
        else
        {
            Label5i.Text = "<script>alert('请填完整的信息')</script>";
        }
    }

解决方案 »

  1.   

    调试时跟一下,看看updatesql是什么
      

  2.   

     if (i != 1) 
                    { 
                        Label5i.Text = " <script>alert('修改成功!') </script>"; 
                    } ??????方法ExecuteNonQuery()是返回语句影响的行数,你这里的判断条件有问题吧?
    if(i>0)
    {
       成功
    }
    else
    {
       失败
    }
      

  3.   

    还有就是“ Label5i.Text = " <script>alert('修改成功!') </script>"; ”  你是不是向永弹出框?
    那就用Response.Write("<script>alert('修改成功')</script>");
      

  4.   

    因为我页面是用DIV+CSS做的要是我不用 Label5i.Text = " <script>alert('修改成功!') </script>"; ”做的话提示之后DIV就会乱掉
      

  5.   

    那就用Page.ClientScript.RegisterStartupScript
      

  6.   

    应该是if(i!=1)
    这里有问题
      

  7.   


    就像2楼说的,if 语句里的判断改成(i>0)试试看吧。
      

  8.   

     if (i != 1) 
                    { 
                        Label5i.Text = " <script>alert('修改成功!') </script>"; 
                    } 
                    else 
                    { 
                        Label5i.Text = " <script>alert('失败!') </script>"; 
                    } 
    如果你的i是0的话也是成功的,其实是失败的。