OleDbConnection myoledbconnection=new OleDbConnection(myConnection);
  OleDbCommand  myoledbcommand = myoledbconnection.CreateCommand();
  myoledbcommand.CommandText="我的sql语句";
  myoledbconnection.Open();try
{
  myoledbcommand.ExecuteNonQuery();
  myoledbconnection.Close();
   Response.Write ("<script>alert(\"提示,录入成功!\");location='yh_up.aspx';</script>");
 Response.Redirect("yh_up.aspx");
}
  catch
 {
    Response.Write ("<script>alert(\"提示,录入失败!\");location='yh_up.aspx';</script>");
 Response.Redirect("yh_up.aspx");

  }

解决方案 »

  1.   

    try
    {
      myoledbcommand.ExecuteNonQuery();
      myoledbconnection.Close();
       Response.Write ("<script>alert(\"提示,录入成功!\");location=\"yh_up.aspx\";</script>");
    }
      catch
     {
        Response.Write ("<script>alert(\"提示,录入失败!\");location=\"yh_up.aspx\";</script>");

      }
      Response.Redirect("yh_up.aspx");
      

  2.   

    you can see eg:Page.RegisterStartupScript("saveok","<script language=javascript>alert(\"保存成功,系统既将返回\");window.location=\"index_1.aspx\";</script>");
      

  3.   

    OleDbConnection myoledbconnection=new OleDbConnection(myConnection);
      OleDbCommand  myoledbcommand = myoledbconnection.CreateCommand();
      myoledbcommand.CommandText="我的sql语句";
      myoledbconnection.Open();try
    {
      myoledbcommand.ExecuteNonQuery();
      myoledbconnection.Close();
      this.Page.RegisterStartupScript("ShowMessage","<script id=clientEventHandler language=javascript>alert('提示,录入成功!');window.location='yh_up.aspx''</script>");
    }
      catch
     {
        Response.Write ("<script>alert(\"提示,录入失败!\");location='yh_up.aspx';</script>");

      }
      Response.Redirect("yh_up.aspx");
      

  4.   

    Page.RegisterStartupScript 这个方法不错 返回到我想应该可以了不过有点想不通,我的程序那里有毛病,我得同事和我的程序一样但却好使,能不能是我们保存的编码方式不一样那?   我想是不是只有这种解释了呢?
      

  5.   

    咳...痛苦ing  也不知道怎么搞的,现在怎么还是这种情况呢?
    用Page.RegisterStartupScript  也不好使  黔驴技穷了   
    高人指点一下
      

  6.   

    Response.Redirect("yh_up.aspx");
    这句去掉!
      

  7.   

    用Page.RegisterClientScriptBlock("ShowMessage","<script id=clientEventHandler language=javascript>alert('提示,录入成功!');window.location='yh_up.aspx''</script>");看看