This is my code where i want to delete the selected checkbox row
private void button3_Click(object sender, EventArgs e)
{
for (int i = 0; i <= dataGridView1.Rows.Count - 1; i++)
{
if (dataGridView1.Rows[i].Cells[0].Value != null)
{
if ((bool)dataGridView1.Rows[i].Cells[0].Value == true)
{
OleDbConnection con = new OleDbConnection();
con.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\MMCLDISPATCH.mdb";
con.Open();
string sql = "delete from DispatchTable where ID='"+i+1+"'";
OleDbDataAdapter da = new OleDbDataAdapter(sql, con);
OleDbCommandBuilder cmd = new OleDbCommandBuilder(da);
DataSet ds = new DataSet();
da.Fill(ds);
dataGridView1.Rows.RemoveAt(i);
}
}
}
I am getting this error:
Data type mismatch in criteria expression.
on this line:
da.Fill(ds);