AcceptRejectRule strange behavior

E

Eric Beaudry

This is an issue that I have seen many times in this forum but was
never answered clearly.

So here it is again:

I have a parent child relation between table A and B this relation is
mark with cascade Update and Casdade delete (because the database does
the same)

I also mark AcceptRejectRule to cascade so when the KEY (this is
important) is modified I hope that the child will not try to re-update
the database and cause a concurency exception. This part works pretty
well.

The problem arise when I add a parent and some children and then
submit the changes to the dataadapter.update method. (and this even if
the tables are sent independently, one update call for each table in
the dataset) After the update of the parent table all the child are
marked as unchanged! That's why nothing happen when I call the update
method with the child table.

Am I wrong or is this some thing strange. Nowhere did I tell that I
want the Add to be cascaded. Am I missing the point around Cascade
Update (I taugh it was for UPDATEs only not for inserts)

So can someone give me (and many others) a work around for this
problem other than: submit the parent add and after resubmit the
children add. because this solution introduce too much coupling
between the backend implementation and the client using the component.
(client must know how to add parent child witch is not realy good in
the current design)

Thanks
 
D

David Sceppa

Eric,

When you submit a pending change by calling
DataAdapter.Update, the DataAdapter implicitly calls the DataRow’
s AcceptChanges method if the update attempt succeeds. Because
you’ve set the ForeignKeyConstraint object’s AcceptRejectRule to
Cascade, this implicit call cascades down to the related child
rows.

I hope this information proves helpful.

David Sceppa
Microsoft
This posting is provided "AS IS" with no warranties,
and confers no rights. You assume all risk for your use.
© 2003 Microsoft Corporation. All rights reserved.
 

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