Deleted row information cannot be accessed through the row. Including with Lambda functions.
24-Apr-1111 Leave a comment
Error message
Deleted row information cannot be accessed through the row.
This may occur when using Lambda functions and in other scenarios as well.
Problem
Dim dtTotal = dsBusiness1.InvoiceDetail.Where(Function(r1) r1.InvoiceNo = cInvoice.InvoiceNo AndAlso r1.RowState <> DataRowState.Deleted)
Solution 1
Dim dtTotal = dsBusiness1.InvoiceDetail.Where(Function(r1) r1.RowState <> DataRowState.Deleted AndAlso r1.InvoiceNo = cInvoice.InvoiceNo)
Solution 2
Use AcceptChanges on datatable to force deletions to clear
Try
Me.MyBindingSource.RemoveCurrent()
Me.MyBindingSource.EndEdit()
Me.ds1.MyTable.AcceptChanges()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try