3

Is there a way to have data tables automatically accept changes or just disable change tracking when making modifications to rows?

When making changes to a datatable, forgetting to call DataTable.AcceptChanges() can cause a real problem.

Neil Knight
  • 47,437
  • 25
  • 129
  • 188
Dustin Davis
  • 14,482
  • 13
  • 63
  • 119

1 Answers1

0

I think the whole point of a DataTable is to have the added benefits of row versioning and change tracking. I do not think you can actually disable this behavior. From MSDN:

Each DataRow in the collection represents a row of data in the table. To commit a change to the value of a column in the row, you must invoke the AcceptChanges method.

Do you want to disable row versioning completely or only in specific occasions?

InBetween
  • 32,319
  • 3
  • 50
  • 90
  • 1
    I want to disable it completely. – Dustin Davis Jan 31 '12 at 17:58
  • "forgetting to call DataTable.AcceptChanges()..." Forgetting to call ANY function can cause problems. If it's really that difficult, you could create your own function MySaveDataTable(...) that called AcceptChanges for you. – Steve Wellens Jan 31 '12 at 18:27