DataRow.AcceptChanges is useless?

A

Andy B

I have the following code:

//delete the row in the table that has ID of 1. This line works fine.
DataSet.Table["Start"].Rows.Find(1).Delete();

//Accept the delete changes to the table. This row returns 'object set to a
null reference' exception. Why?
DataSet.Tables["Start"].Rows.Find(1).AcceptChanges();

Why does this happen if the DataRow.Delete method page on msdn says that you
need to call DataRow.AcceptChanges() after a delete to make the rows
actually delete?
 
C

ChigbuaUmuenu

Simply call Dataset.Tables("Start").AcceptChanges()

The row has been deleted. Call DataRow.AcceptChanges() when you update or
add new record to a datarow.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top