Hi, I am try to delete a selected row from a datagridview and an MS Access Database, I can get it to delete from the datagridview but not the database, does anybody know why? here is my current code: Code: { int cnt = dataGridView1.SelectedRows.Count; for (int i = 0; i < cnt; i++) { if (this.dataGridView1.SelectedRows.Count > 0 && this.dataGridView1.SelectedRows[0].Index != this.dataGridView1.Rows.Count - 1) { this.dataGridView1.Rows.RemoveAt( this.dataGridView1.SelectedRows[0].Index); string queryDeleteString = ""; OleDbCommand sqlDelete = new OleDbCommand(); queryDeleteString = ("DELETE FROM AddAccount WHERE AccoutnID = " + i + ""); sqlDelete.CommandText = queryDeleteString; sqlDelete.Connection = database; sqlDelete.ExecuteNonQuery(); database.Close(); dataGridView1.Refresh(); } } } Thanks
How do you know you didn't delete it from the database? Is AutoCommit on or off? Is the column in the DB really called "AccoutnID"? as opposed to AccountID (transposing N and T)