Home All Groups Group Topic Archive Search About
Author
3 Aug 2006 8:51 PM
Al
I'd like to know if there were any changes in the DataSet which was
populated by reading XML file. 6 DataTables with data or just structure with
no data inside of it.
I think about this scenario:
I create 2 datasets and populate both from the same XML file. Then the first
one is used as DataSource for many controls and the second one is untouched.
If there were some changes in the first one, I'd like to know it and would
like to compare with the second one. I don't know how. Everything I need to
know is just were there any changes or not. If yes I will ask the user if he
wants to save them back into XML file.

So the question again: How do I compare 2 datasets? Or maybe somebody can
suggest a better way to catch changes?

Thank you
Al

Author
3 Aug 2006 9:56 PM
Kerry Moorman
Al,

The dataset has a HasChanges method that might work for you.

Kerry Moorman


Show quoteHide quote
"Al" wrote:

> I'd like to know if there were any changes in the DataSet which was
> populated by reading XML file. 6 DataTables with data or just structure with
> no data inside of it.
> I think about this scenario:
> I create 2 datasets and populate both from the same XML file. Then the first
> one is used as DataSource for many controls and the second one is untouched.
> If there were some changes in the first one, I'd like to know it and would
> like to compare with the second one. I don't know how. Everything I need to
> know is just were there any changes or not. If yes I will ask the user if he
> wants to save them back into XML file.
>
> So the question again: How do I compare 2 datasets? Or maybe somebody can
> suggest a better way to catch changes?
>
> Thank you
> Al
>
>
>
Author
3 Aug 2006 10:50 PM
Al
Unfortunately HasChanges method returns True even right after populating
DataSet from XML file. I do not know why.
I also tried to populate another DataSet with GetChanges method. No success
too - the resulting DataSet has rows in Tables. Do not know why either.

Al


Show quoteHide quote
"Kerry Moorman" <KerryMoor***@discussions.microsoft.com> wrote in message
news:290AE629-D4CB-44CC-AB16-0BCD87C21CB1@microsoft.com...
> Al,
>
> The dataset has a HasChanges method that might work for you.
>
> Kerry Moorman
>
>
> "Al" wrote:
>
>> I'd like to know if there were any changes in the DataSet which was
>> populated by reading XML file. 6 DataTables with data or just structure
>> with
>> no data inside of it.
>> I think about this scenario:
>> I create 2 datasets and populate both from the same XML file. Then the
>> first
>> one is used as DataSource for many controls and the second one is
>> untouched.
>> If there were some changes in the first one, I'd like to know it and
>> would
>> like to compare with the second one. I don't know how. Everything I need
>> to
>> know is just were there any changes or not. If yes I will ask the user if
>> he
>> wants to save them back into XML file.
>>
>> So the question again: How do I compare 2 datasets? Or maybe somebody can
>> suggest a better way to catch changes?
>>
>> Thank you
>> Al
>>
>>
>>
Author
3 Aug 2006 11:18 PM
Kerry Moorman
Al,

Have you tried calling the dataset's AcceptChanges method immediately after
initially loading it? After that, HasChanges may correctly reflect changes
since loading.

Kerry Moorman


Show quoteHide quote
"Al" wrote:

> Unfortunately HasChanges method returns True even right after populating
> DataSet from XML file. I do not know why.
> I also tried to populate another DataSet with GetChanges method. No success
> too - the resulting DataSet has rows in Tables. Do not know why either.
>
> Al
>
>
> "Kerry Moorman" <KerryMoor***@discussions.microsoft.com> wrote in message
> news:290AE629-D4CB-44CC-AB16-0BCD87C21CB1@microsoft.com...
> > Al,
> >
> > The dataset has a HasChanges method that might work for you.
> >
> > Kerry Moorman
> >
> >
> > "Al" wrote:
> >
> >> I'd like to know if there were any changes in the DataSet which was
> >> populated by reading XML file. 6 DataTables with data or just structure
> >> with
> >> no data inside of it.
> >> I think about this scenario:
> >> I create 2 datasets and populate both from the same XML file. Then the
> >> first
> >> one is used as DataSource for many controls and the second one is
> >> untouched.
> >> If there were some changes in the first one, I'd like to know it and
> >> would
> >> like to compare with the second one. I don't know how. Everything I need
> >> to
> >> know is just were there any changes or not. If yes I will ask the user if
> >> he
> >> wants to save them back into XML file.
> >>
> >> So the question again: How do I compare 2 datasets? Or maybe somebody can
> >> suggest a better way to catch changes?
> >>
> >> Thank you
> >> Al
> >>
> >>
> >>
>
>
>
Author
4 Aug 2006 12:16 AM
Al
I called AcceptChanges method as you suggested and now HasChanges returns
False before any change as well as after changes.

Al

Show quoteHide quote
"Kerry Moorman" <KerryMoor***@discussions.microsoft.com> wrote in message
news:715FAEDC-56EE-429B-9EA9-9AEE3FB352F2@microsoft.com...
> Al,
>
> Have you tried calling the dataset's AcceptChanges method immediately
> after
> initially loading it? After that, HasChanges may correctly reflect changes
> since loading.
>
> Kerry Moorman
>
>
> "Al" wrote:
>
>> Unfortunately HasChanges method returns True even right after populating
>> DataSet from XML file. I do not know why.
>> I also tried to populate another DataSet with GetChanges method. No
>> success
>> too - the resulting DataSet has rows in Tables. Do not know why either.
>>
>> Al
>>
>>
>> "Kerry Moorman" <KerryMoor***@discussions.microsoft.com> wrote in message
>> news:290AE629-D4CB-44CC-AB16-0BCD87C21CB1@microsoft.com...
>> > Al,
>> >
>> > The dataset has a HasChanges method that might work for you.
>> >
>> > Kerry Moorman
>> >
>> >
>> > "Al" wrote:
>> >
>> >> I'd like to know if there were any changes in the DataSet which was
>> >> populated by reading XML file. 6 DataTables with data or just
>> >> structure
>> >> with
>> >> no data inside of it.
>> >> I think about this scenario:
>> >> I create 2 datasets and populate both from the same XML file. Then the
>> >> first
>> >> one is used as DataSource for many controls and the second one is
>> >> untouched.
>> >> If there were some changes in the first one, I'd like to know it and
>> >> would
>> >> like to compare with the second one. I don't know how. Everything I
>> >> need
>> >> to
>> >> know is just were there any changes or not. If yes I will ask the user
>> >> if
>> >> he
>> >> wants to save them back into XML file.
>> >>
>> >> So the question again: How do I compare 2 datasets? Or maybe somebody
>> >> can
>> >> suggest a better way to catch changes?
>> >>
>> >> Thank you
>> >> Al
>> >>
>> >>
>> >>
>>
>>
>>
Author
4 Aug 2006 12:26 AM
Al
I cannot be sure yet, but I think with your help I found what is wrong. I
used to call AcceptChanges method every time I'm making changes in any
DataTable. I was thinking that this method will save my changes in the
DataSet only and without calling this method I will lose the changes I make.
I commented all AcceptChanges calls and now HasChanges seems to work
properly.
So for now I do not need to to worry about losing any change I make and I
just need to ask the user if he wants to save data into XML only in case
when HasChanges returns True.

Thank you very much

Al

Show quoteHide quote
"Kerry Moorman" <KerryMoor***@discussions.microsoft.com> wrote in message
news:715FAEDC-56EE-429B-9EA9-9AEE3FB352F2@microsoft.com...
> Al,
>
> Have you tried calling the dataset's AcceptChanges method immediately
> after
> initially loading it? After that, HasChanges may correctly reflect changes
> since loading.
>
> Kerry Moorman
>
>
> "Al" wrote:
>
>> Unfortunately HasChanges method returns True even right after populating
>> DataSet from XML file. I do not know why.
>> I also tried to populate another DataSet with GetChanges method. No
>> success
>> too - the resulting DataSet has rows in Tables. Do not know why either.
>>
>> Al
>>
>>
>> "Kerry Moorman" <KerryMoor***@discussions.microsoft.com> wrote in message
>> news:290AE629-D4CB-44CC-AB16-0BCD87C21CB1@microsoft.com...
>> > Al,
>> >
>> > The dataset has a HasChanges method that might work for you.
>> >
>> > Kerry Moorman
>> >
>> >
>> > "Al" wrote:
>> >
>> >> I'd like to know if there were any changes in the DataSet which was
>> >> populated by reading XML file. 6 DataTables with data or just
>> >> structure
>> >> with
>> >> no data inside of it.
>> >> I think about this scenario:
>> >> I create 2 datasets and populate both from the same XML file. Then the
>> >> first
>> >> one is used as DataSource for many controls and the second one is
>> >> untouched.
>> >> If there were some changes in the first one, I'd like to know it and
>> >> would
>> >> like to compare with the second one. I don't know how. Everything I
>> >> need
>> >> to
>> >> know is just were there any changes or not. If yes I will ask the user
>> >> if
>> >> he
>> >> wants to save them back into XML file.
>> >>
>> >> So the question again: How do I compare 2 datasets? Or maybe somebody
>> >> can
>> >> suggest a better way to catch changes?
>> >>
>> >> Thank you
>> >> Al
>> >>
>> >>
>> >>
>>
>>
>>
Author
4 Aug 2006 6:45 AM
Miha Markic [MVP C#]
"Al" <a*@newsgroups.com> wrote in message
news:%23idoty1tGHA.2392@TK2MSFTNGP05.phx.gbl...
>I cannot be sure yet, but I think with your help I found what is wrong. I
>used to call AcceptChanges method every time I'm making changes in any
>DataTable. I was thinking that this method will save my changes in the
>DataSet only and without calling this method I will lose the changes I
>make.
> I commented all AcceptChanges calls and now HasChanges seems to work
> properly.

Yes, this is common misundestanding of what AcceptChanges really does. I
guess the name is misleading...

--
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/