1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
   |    protected void btnValiderAjoutEnfant_Click(object sender, EventArgs e)
        {
            try
            {
                c.cmd = c.cn.CreateCommand();
                c.cmd.CommandText = "insert into Enfants (Prenom , DateNaissance , Scolarise,Activite, PPR)  values ('" + TextBox_prenomenfant + "','" + TextBox_dnenfant + "','" + TextBox_scol + "','" + TextBox_activite + "'," + Session["code"] + ")";
             if (c.cn.State == System.Data.ConnectionState.Closed)
                 {
                     c.cn.Open();
                 }
                c.cmd.ExecuteNonQuery();
                gv_enfant.DataBind();
 
            }
            catch (Exception ex)
            {
              Response.Write("<script>alert ('Erreur d'ajout!')</script>");        
            }
             finally
            {
                if (c.cn.State == ConnectionState.Open)
                {
                    c.cn.Close();
                }
            }
        } | 
Partager