Having problems deleting a row

  • Thread starter Thread starter Carl Mercier
  • Start date Start date
C

Carl Mercier

Hi,

I'm trying to delete a row from a datatable at runtime but an exception is
thrown. I have no clue why since I'm not even using an iterator.

Here's my code:

' Search for deleted items at client side
For Each t As DataTable In dsWeb.Tables
For i As Integer = 0 To t.Rows.Count - 1
Dim dr As DataRow = t.Rows(i)
Dim foundRow As DataRow =
dsClient.Tables(t.TableName).Rows.Find(New Object() {dr(0), auth.User})

If foundRow Is Nothing Then
' this item was deleted
t.Rows(i).Delete() '<<<------- Exception thrown
here
Else
' Do nothing
End If
Next
Next

The exception is of type DeletedRowInaccessibleException (.Message = Deleted
row information cannot be accessed through the row).

I made sure that every row i was trying to delete is RowState = Unchanged.
I also tried many other ways of looping and deleting the rows but without
much success.

Can anyone help here?

Thanks!

Carl
 
Hi Carl,

I've didn't read well your message.
Your problem might lie here:
dsClient.Tables(t.TableName).Rows.Find(New Object() {dr(0), auth.User})
You use dr(0) on deleted row.
 
Miha,

The problem is really on the .Delete line. I tried what you said anyway
but it did not help.

I'm lost :(

Carl
 
Hi Carl,

Since we are going in circles, you might send me a really simple sample if
you wish to.
 
Back
Top