What could be causing this while updating a DataTable?

  • Thread starter Thread starter Benton
  • Start date Start date
B

Benton

Hi there,

I am getting this exception

"Deleted row information cannot be accessed through the row"

when trying to update a datatable with an adapter:

mAdapter.Update(mTable); <== exception here

After struggling with this for hours, I am now looking for a more generic
answer, i.e., does anyone know the possible scenarios in which this
exception might occur inside the Update method. What "mistake" on my side
could be triggering it.

The exception usually happens if I:

1) Delete all rows in the table:

for (int i = 0; i < mTable.Rows.Count; i++)
mTable.Rows.Delete();

2) Add new rows to the table => mTable.Rows.Add(newRow);

3) Call the update method => adapter.Update();

Thanks in advance for any opinions,

-Benton
 
Are you handling any adapter or datatable events? I am wondering if you are
handling an event that is firing here and your handler is throwing the
exception.

If you have a small set of complete code to reproduce the problem that would
be helpful..
 
Are you handling any adapter or datatable events? I am wondering if you
are handling an event that is firing here and your handler is throwing the
exception.

No, no events/handlers of any kind. Exception is coming from inside the
Update method.
If you have a small set of complete code to reproduce the problem that
would be helpful..

I appreciate it. I ended up getting rid of the adapter and doing things
manually, i.e., iterating the datarows, inspecting the RowState and issuing
insert, update, and delete commands accordingly. For the delete command I
used the 'DataRowVersion.Original' parameter when feeding row column values
to the command parameters (somehow the adapter was not doing this I guess),
and everything went fine. <Sigh> I didn't like the adapter very much in the
first place. ;-)

Best regards,

-Benton
 
Back
Top