DS.RejectChanges

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

Guest

VS2003 C#
Hi,

I have a list box showing the 'master' records & a datagrid displaying the
'details' of the master records. These are databound to a dataset.

I'm trying to use the RejectChanges method to remove rows that I've added.
This is done in the catch block of a try catch set, but even after I throw an
error & the code gets directed to ds.rejectChanges, all the rows added to the
two tbls are still shown in the list box/datagrid until I close & reopen the
application.

How can i remove these rows that I've added, from the dataset? Why is
RejectChanges not working? Am i overlooking doing something? This has got me
stumped...

Thanks for any ideas in advance.
Ant
 
Ant,

The rejectchanges is not possible anymore if an acceptchanges is done
explicitly or implicitly as by instance is done by the dataadapter.update
method.

Cor
 
Thanks Cor, that helps me.

So I'm guessing the best way to 'roll back' the added row(s) would be to
manually remove them in the catch block? is there a better, more accepted way
of doing this or is this apporach fine?

Thanks very much for your help.

Ant
 
Sure,

Do all the operations on copy (DataSet.GetChanges or DataSet.Copy) of
dataset and if operations fail then just forget this copy. If it succeeds
then merge copy with original.
 
Thanks very much, that's great.

Ant



Miha Markic said:
Sure,

Do all the operations on copy (DataSet.GetChanges or DataSet.Copy) of
dataset and if operations fail then just forget this copy. If it succeeds
then merge copy with original.

--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

Ant said:
Thanks Cor, that helps me.

So I'm guessing the best way to 'roll back' the added row(s) would be to
manually remove them in the catch block? is there a better, more accepted
way
of doing this or is this apporach fine?

Thanks very much for your help.

Ant
 
Back
Top