"transactions" on a DataSet object

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

What I want to do is to somehow start a "transaction" on a DataSet object.
Once the "transaction" is started I will be making changes to the DataSet. If
the user wants to save the changes then I essentially don't need to do
anything with the DataSet. BUT, if the user wants to throw away all changes
then I want to revert back to the state the DataSet was in before the
"transaction" was started. I can always make a copy in memory of the DataSet
but that seems to be resource intensive. Are there any other ways to save the
state/date of the DataSet and then restore it back to this state?

Regards,
Chris
 
cyourch said:
Hi,

What I want to do is to somehow start a "transaction" on a DataSet object.
Once the "transaction" is started I will be making changes to the DataSet.
If
the user wants to save the changes then I essentially don't need to do
anything with the DataSet. BUT, if the user wants to throw away all
changes
then I want to revert back to the state the DataSet was in before the
"transaction" was started. I can always make a copy in memory of the
DataSet
but that seems to be resource intensive. Are there any other ways to save
the
state/date of the DataSet and then restore it back to this state?

DataSet.RejectChanges rolls back all changes since the last
DataSet.AcceptChanges.

David
 
No. That will throw away any changes that are pending just before I would
start my "transaction".
 
That depends on when you call RejectChanges. You can call RejectChanges on
just one row at a time after you decide you need to roll them back.

There is not transactional capability per se in the DataSet object - you
can use GetChanges to create a dataset with only the changed values - then
as they are processed and you determine that they are safe to commit, call
AcceptChanges on the original on a row by row basis.
 
That won't work either. If the row in question was changed already (call it
change 1), then I change it again (change 2) and finally 'rollback" the
changes via RejectChanges() then "change 1" is lost.

What I need to do is make a deep copy of each row that will have changes or
gets deleted and also track each row that is added. With this information I
can completely reconstruct the DataSet if I need to.

Maybe a class derived from DataSet that processes the needed events might do
the trick.
 
Back
Top