Bonjour,
j'ai fait ce code pour un bouton "botton_quitter" pour quitter une fenetre. avec un message d'enregistrement.. le probléme cette fonction ne fonctionne pas bien..

surement j'ai mal ecri mon code.

Pd,

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
 
 private void button_quitter_Click(object sender, EventArgs e)
        {
 
                if (MessageBox.Show("Do you want to save the change you made to 'PPA base' ?", "leave the application", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                {
   try
                    {
                        // Chaîne de connexion
                        string connectString = @"Data Source=RENNDXPRDL2596\SQLEXPRESS;Initial Catalog=hafid;Persist Security Info=True;User ID=sa;Password=rabat99";
 
                        // Objet connection
                        SqlConnection connection = new SqlConnection(connectString);
                        // Ouverture
                        connection.Open();
                        SqlCommand command = new SqlCommand("UPDATE [Table_test] SET A=@A,B=@A.....
 
                    command.ExecuteNonQuery();
 
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString());
                    }
merci