I have problem when I delete multichecked rows with this button. It only delete first row. cell_dellklient is the name of checkbox in dataGridView1 yes is the true value of checkbox
Please help
private void button2_Click(object sender, EventArgs e) { foreach (DataGridViewRow row in dataGridView1.Rows) { con.Open();
object cell = row.Cells["cell_delklient"].Value;
if (cell == "yes")
{
SqlCommand cmd = new SqlCommand("Delete From Klienci where Nazwa ='" + row.Cells[0].Value.ToString() + "'", con);
cmd.ExecuteNonQuery();
con.Close();
wyczytywaniegridu();
}
con.Close();
}
Aucun commentaire:
Enregistrer un commentaire