DataRow.AcceptChanges is useless?

  • Thread starter Thread starter Andy B
  • Start date Start date
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?
 
Simply call Dataset.Tables("Start").AcceptChanges()

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