Update and AcceptChanges

K

Katrin Bibas

Hello,

I have a question regarding AcceptChanges. In the framework
documentation there is written that the Update method of the
DataAdapter calls AcceptChanges automatically. And this is how it
seems to be working. But I recently read the book for the MOC 2609A,
and there is written that you have to call AcceptChanges by yourself
after Update. Did this behaviour change from version 1.0 to 1.1 or why
did they describe it this way?

Thanks
Katrin
 
W

William Ryan eMVP

No, you don't have to call AcceptChanges after update. If you use
GetChanges though and get the changes into another dataset, you may want to
manually call it - there are obviously other scenarios where you would but
under 'normal' scenarios, it's no necessary b/c it's called on each row as
they are updated. In the 2.0 framework there's a new Property of the
DataSet as well as the DataTable - .AccpetChangesDuringUpdate
http://www.knowdotnet.com/articles/acceptchangesduringupdate.html that can
give you some cool new flexiblity.

--

W.G. Ryan, eMVP

Have an opinion on the effectiveness of Microsoft Embedded newsgroups?
Let Microsoft know!
https://www.windowsembeddedeval.com/community/newsgroups
 
K

Katrin Bibas

But why is it used in msdn training 2609? There is written:
....
After the Update method resolves your changes back to the data source, you
must notify the DataSet that the database accepted the changes. You can do this
by using the AcceptChanges method of the DataSet ...

I just wondered why it is explained there in this way.

Thank you.
Katrin
 
C

Cor Ligthert

Hi Katrin,

I do not know the mdsn training 2609, however as Bill wrote, "you don't have
to call" it, which does not mean "you would not call" it.

After an update the acceptchanges is automaticly done when the update is
done with the original dataset in that dataset. When you first gets a copy
of the rows that have changed (by instance by using the getchanges) than the
update is not done with the original database and than you have to use the
AcceptChanges on the original dataset. Than the updates are marked in a kind
of last update trip state of the database. (Rows are set to not changed
after the update). After that another user can have changed it again of
course so do not mix it up with a current state. That it is in a single user
environment.

I hope this helps?

Cor
 
K

Katrin Bibas

I understand it and I know how to use it, I just wondered why it's
wrong in the msdn training. Because I know people using the books from
that training, and there is obviously an error in that book about this
topic. Those trainings are written by Microsoft, so why do they
explain it there in the wrong way? It is not just a typo, it is
explained this way on several pages. So I thought maybe it changed
from framework version 1.0 to 1.1 ... (The book was written with
version 1.0)

But thank you for your detailed explanations :)

Katrin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top