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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
   |  try
            {
                MySqlConnection connection = new MySqlConnection("SERVER=************; Database=************;UID=************;PASSWORD=************");
                MySqlCommand commande = new MySqlCommand();
 
                commande.Connection = connection;
 
                //Ordre SQL
 
                commande.CommandText = @"UPDATE fiche 
                                                SET Obj_FI = @Obj_FI, 
                                                Des_FI= @Des_FI, 
                                                Duree_FI= @Duree_FI,
                                                Local_FI = @Local_FI, 
                                                Cont_FI = @Cont_FI, 
                                                Situa_FI = @Situa_FI, 
                                                Lieu_FI = @Lieu_FI 
                                         WHERE ficheid = @ficheid;";
 
                //Paramètres
 
                commande.Parameters.AddWithValue("ficheid", Fiche.ficheid);
                commande.Parameters.AddWithValue("Obj_FI", Fiche.Obj_FI);
                commande.Parameters.AddWithValue("Des_FI", Fiche.Des_FI);
                commande.Parameters.AddWithValue("Duree_FI", Fiche.Duree_FI);
                commande.Parameters.AddWithValue("Local_FI", Fiche.Local_FI);
                commande.Parameters.AddWithValue("Cont_FI", Fiche.Cont_FI);
                commande.Parameters.AddWithValue("Situa_FI", Fiche.Situa_FI);
                commande.Parameters.AddWithValue("Lieu_FI", Fiche.Lieu_FI);
 
                //Connexion + exécution de l'ordre sql + déconnection
 
                connection.Open();
 
                commande.ExecuteNonQuery();
 
                connection.Close();
            }
            catch (Exception exception)
            {
                throw exception;  
            } | 
Partager