防刷新多次提交

如果你是根据参数来插入数据的话可以用此方法

    protected void Page_PreInit(object sender, EventArgs e)
    {
        if (Request.QueryString["id"] != null)
        {
            SqlCommand cmd = new SqlCommand("insert into jobs values(@job_desc,@min_lvl,@max_lvl)", con);
            con.Open();
            cmd.Parameters.Add("@job_desc", SqlDbType.VarChar).Value = "luca";
            cmd.Parameters.Add("@min_lvl", SqlDbType.Int).Value = 50;
            cmd.Parameters.Add("@max_lvl", SqlDbType.Int).Value = 40;
            cmd.ExecuteNonQuery();
            con.Close();
            Response.Redirect("~/default2.aspx",true);
        }

    
       
    }

posted @ 2008-06-13 17:03  思然  阅读(268)  评论(0编辑  收藏  举报