Home All Groups Group Topic Archive Search About
Author
13 Nov 2006 2:21 AM
Ant
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

Author
13 Nov 2006 5:28 AM
Cor Ligthert [MVP]
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

Show quote
"Ant" <A**@discussions.microsoft.com> schreef in bericht
news:4853538E-4CA0-4427-877E-C5F610D055CD@microsoft.com...
> 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
Author
13 Nov 2006 5:42 AM
Ant
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

Show quote
"Cor Ligthert [MVP]" wrote:

> 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
>
> "Ant" <A**@discussions.microsoft.com> schreef in bericht
> news:4853538E-4CA0-4427-877E-C5F610D055CD@microsoft.com...
> > 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
>
>
>
Author
13 Nov 2006 9:13 AM
Miha Markic [MVP C#]
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/

Show quote
"Ant" <A**@discussions.microsoft.com> wrote in message
news:CE31911A-7E7E-402C-97DD-95A7F7E9A39F@microsoft.com...
> 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
>
> "Cor Ligthert [MVP]" wrote:
>
>> 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
>>
>> "Ant" <A**@discussions.microsoft.com> schreef in bericht
>> news:4853538E-4CA0-4427-877E-C5F610D055CD@microsoft.com...
>> > 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
>>
>>
>>
Author
13 Nov 2006 1:51 PM
Ant
Thanks very much, that's great.

Ant



Show quote
"Miha Markic [MVP C#]" wrote:

> 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" <A**@discussions.microsoft.com> wrote in message
> news:CE31911A-7E7E-402C-97DD-95A7F7E9A39F@microsoft.com...
> > 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
> >
> > "Cor Ligthert [MVP]" wrote:
> >
> >> 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
> >>
> >> "Ant" <A**@discussions.microsoft.com> schreef in bericht
> >> news:4853538E-4CA0-4427-877E-C5F610D055CD@microsoft.com...
> >> > 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
> >>
> >>
> >>
>
>

AddThis Social Bookmark Button