SqlCommand ccmd = new SqlCommand("update main set bd='已' where id='" + hf1.Value + "'", conn);
ccmd.ExecuteNonQuery();
            
Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('报到成功')</script>");一、想要实现 SQL update 成功的话,才弹出报到成功的框框,怎么样的if语句可以实现?我现在的是无论更新成功与否,都会弹这个报到成功的框框二、还有报到成功这个框框出来之后,点击“确定”,能关闭当前页,怎么来实现?

解决方案 »

  1.   


    if(ccmd.ExecuteNonQuery()>0)
    {
    Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('报到成功')</script>");
    }
      

  2.   


            SqlCommand ccmd = new SqlCommand("update main set bd='已' where id='" + hf1.Value + "'", conn);
            if (Convert.ToInt32(ccmd.ExecuteNonQuery()) > 0)
            {
                ClientScript.RegisterStartupScript(Page.GetType(), "", "<script>alert('报到成功');window.close();</script>");
            }
            else
            {
                ClientScript.RegisterStartupScript(Page.GetType(), "", "<script>alert('any questions');</script>");
            }
      

  3.   

    int row= ccmd.ExecuteNonQuery();
    if(row>0)
    {
    Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('报到成功')</script>");
    }
      

  4.   

    bool flag = false;
    try
    {
      SqlCommand ccmd = new SqlCommand("update main set bd='已' where id='" + hf1.Value + "'", conn);
      flag = ccmd.ExecuteNonQuery() > 0;
     }
    catch { }string message = string.Empty;
    if (flag)
        message="报到成功";
    else
        message="报到失败";Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('" + message + "')</script>");