I have a Datatable (dtP) filled by an OledbDataAdapter(daP) from an Access database.
Textboxes on the Form are bound to the dtP
I have 4 buttons that allow me to move through the rows (Next,Previous,First and Last) and a buttons to Update changes in a row and another button to delete a row.
Everything works fine, I can add rows, change data in a row except I am not able to delete a row.
The delete button which calls the following:
>>> CurrID <<< is the indexed ID of the current row
Private Sub bDel_Click(sender As Object, e As EventArgs) Handles bDel.Click
For i As Integer = 0 To dtP.Rows.Count - 1
Dim dr As DataRow = dtP.Rows(i)
If dr("ID") = CurrID Then
dr.Delete()
End If
Next
dtP.AcceptChanges()
End Sub
the application goes through without giving any error,I’ve put a breakpoint on the
dr.delete
line to make sure it goes through it, and it does, but the row does not get deleted.
I also tried
dr.remove
instead of
dr.delete
it does not work neither.
Any ideas?
Thank you
What I have tried:
I have also tried:
Private Sub bDel_Click(sender As Object, e As EventArgs) Handles bDel.Click
For i As Integer = 0 To dtP.Rows.Count - 1
Dim dr As DataRow = dtP.Rows(i)
If dr("ID") = CurrID Then
dr.remove()
End If
Next
dtP.AcceptChanges()
End Sub