Dataset Update / AcceptChange / RejectChanges

  • Thread starter Thread starter TheNortonZ
  • Start date Start date
T

TheNortonZ

I have a couple of questions about how the ds.Update, AcceptChanges,
RejectChanges work.

I have a dataset with 8 tables. I perform a ds.Update separately for each
one of these tables. Most of these tables are not related.

1. Should I be calling ds.AcceptChanges right after the call to ds.Update?
2. Is there a point in time when AcceptChanges will be called automatically.
3. Assume that I do not call AcceptChanges. If I return to the calling
component and then do a ds.RejectChanges, do all of my ds.Updates get
cancelled?

I am trying to figure out when it is past the point of no return to do a
ds.RejectChanges. Given that I have so many ds.Update statements being
called, it would seem that I might not be able to roll all of these back
since the changes are in the database already.

Thanks!

Norton
 
Hi,

TheNortonZ said:
I have a couple of questions about how the ds.Update, AcceptChanges,
RejectChanges work.

I have a dataset with 8 tables. I perform a ds.Update separately for each
one of these tables. Most of these tables are not related.

1. Should I be calling ds.AcceptChanges right after the call to ds.Update?

No need - it is called implicitly.
2. Is there a point in time when AcceptChanges will be called
automatically.

See above.
Also after Fill method (depends on AcceptChangesDuringFill parameter)
3. Assume that I do not call AcceptChanges. If I return to the calling
component and then do a ds.RejectChanges, do all of my ds.Updates get
cancelled?

Theoretically yes, but no - see 1.
I am trying to figure out when it is past the point of no return to do a
ds.RejectChanges. Given that I have so many ds.Update statements being
called, it would seem that I might not be able to roll all of these back
since the changes are in the database already.

Update certainly.
However, if you want to persist changes, you should do Update on
Dataset.GetChanges copy.
 
Miha,

Thanks for answering. I am not quite sure I understand your last statement
though.

So, if I perform an update, which implicitly calls AcceptChanges and then
later I call RejectChanges, will all Update (which includes inserts,
updates, deletes) to the database be rolled back?

My changes are already being persisted to the database via the .Update
command. What is the advantage of using the GetChanges command?

Thanks.

Norton
 
Back
Top