I want to delete multiple data from C# Windows form application. I used following code but not working.
It shows an error. N.B: My table ID data type is Integer. Sorry i uploaded a wrong image.
foreach (DataGridViewRow data in dataGridView1.Rows)
{
if (bool.Parse(data.Cells[0].Value.ToString()))
{
conn.con.Open();
OleDbCommand command = new OleDbCommand("Delete FROM tblTransaction WHERE ID='" + data.Cells[1].Value.ToString() + "'", conn.con);
if (DialogResult.Yes == MessageBox.Show("Do you want to Delete this record?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Warning))
{
command.ExecuteNonQuery();
MessageBox.Show("Data Deleted Successfully", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else if (DialogResult == DialogResult.No)
{
//nothing to do
}
conn.con.Close();
}
}