I am having trouble with deleting one to multiply rows in DataGridView
by selecting check box and clicking the delete button. When i click the delete button nothing happens and neither appears if there is an error.
Here is my code
SqlConnection cn = new SqlConnection("Data Source=.\\SQLEXPRESS; Initial Catalog=DatabaseName;Integrated Security=True");
SqlCommand cmd = new SqlCommand();
SqlDataReader dr;
private void btnDeleteCust_Click(object sender, EventArgs e)
{
foreach (DataGridViewRow item in gridCustomer.Rows)
{
if (bool.Parse(item.Cells[6].Value.ToString()))
{
cn.Open();
cmd.CommandText = "delete from Customer where customerID = '" + item.Cells[0].Value.ToString() + "'";
cmd.ExecuteNonQuery();
cn.Close();
}
}
}