Implicit acceptchanges after row update in parent child dataset

G

Guest

Hello anyone,

The last couple of days I have tried to find the best practice on updating
parent and child rows in a dataset. Ideally I want to allow the dataset to
consist of a mix of modified, deleted and inserted child and/or parent rows.

To make things work well I have turned all cascading options on. This way
when someone deleted the parent de child rows are automaticly deleted aswell.
Furthermore, when my busniess layer decides that validation rules do not
allow the parent to be deleted a rejectchanges on the parent rejects the
child rows as well.

So far so good, but problems arise when the parent and child are both
modifed. When I update the the parent (with success) an implicit Accept
Changes is done ont the parent row which cascades to the child rows which
still needed to be updated to the database.

Using Getchanges and turning of the cascadinf accept reject changes have
given me other problems which I'll not mention for now (unless asked for).

Could anyone tell me how to avoid the implicit acceptchanges on an updated
row or direct me to documents and/or books that go indepth on updating
parent/child datasets imcluding own validation, concurrency control and
cascading options.

Many thanks in advance,
WiZZiX
 
R

Ravi[MSFT]

In next version of ADO.NET, you can set AcceptChangesDuringUpdate property
on SqlDataAdapter. SqlDataAdapter would then check this property to decide
whether AcceptChanges should be called after an Update or not. In VS 2003,
you might have to resort to turning off the cascading option on FK
constraint AcceptRejectRule.

As a side note: you may have noticed that there is a corresponding property
for Fill called AcceptChangesDuringFill which is also present in VS 2003.
-Ravi
 
G

Guest

Thanks Ravi,

Meanwhile I found out that I can change the status in the RowUpdated Event
to SkipCurrentRow to achieve the same thing. I don't know if skipping the row
has any other consequences, but until it becomes a build in feature I'm
probably stuck with it.
 
K

Kevin Yu [MSFT]

Hi WiZZiX,

As far as I know, SkipCurrentRow only abandons the current row update. I
haven't heard of other side effects yet. HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 

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