Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionprivate void button1_Click(object sender, EventArgs e) { cnn.Open(); for(int i=0; i < (dataGridVEmploye.Rows.Count); i++) { if(dataGridVEmploye.Rows[i].Cells["Column1"].Value != null) { SqlCommand cmd_req = new SqlCommand("select Id_Section from section where Id_Section='" + combo_Section.SelectedValue + "' ",cnn); cmd_req.CommandType = CommandType.Text; SqlDataAdapter da_req = new SqlDataAdapter(cmd_req); DataTable dt_req = new DataTable(); da_req.Fill(dt_req); #region//*** CheckBox Valider string test; if (Convert.ToString(dataGridVEmploye.Rows[i].Cells["Column1"].Value) == "null") { test = "false"; } else { test = "true"; } #endregion int compt = dt_req.Rows.Count; string chaineInsert = "INSERT INTO Employe_affectation VALUES(" + (compt + 1) + ") "; SqlCommand cmdAjouter = new SqlCommand(chaineInsert, cnn); cmdAjouter.Connection = cnn; cmdAjouter.CommandType = CommandType.Text; cmdAjouter.ExecuteNonQuery(); MessageBox.Show("bien"); cnn.Close(); } } dataGridVEmploye.Rows.Clear(); MessageBox.Show("Added");