UpdateDataSet Multiple tables

Topics: Data Access Application Block
Sep 11, 2007 at 2:49 PM
I am using Enterprise Library 2.0 and the data access application block
I have a dataset with 2 tables with a relation between them. (Customer, Orders)
In the database I have the same tables with a foreign key relation
I insert/update/delete both tables in the dataset and set the primary key in orders by orderrow.SetParentRow(customerrow)

When in my DataAccess Layer I first call UpdateDataset for the customer table and then UpdateDataset for the Orders table.
Everything works fine as long as I Insert or update rows.
But when I try to delete a customer and all his orders I get an
Cannot make this change because constraints are enforced on relation exception.
This because I try to delete rows in customer that have childs in orders table, but I have to call the Customers table first in order to get the Insert to work.
What am I doing wrong?

Best Regards
Sven Hasselblad
Sep 13, 2007 at 12:11 PM
I found a workaround.
I added " on delete cascade" on the relation in the database.
But the question is still interesting.
How do I solve this problem without using cascade delete?

Best regards
Sven Hasselblad
Sep 17, 2007 at 3:50 PM
Hi Sven,

Do you mean how to solve this problem without using cascade deletes as a mechanism, or without specifying it in the database?
My understanding is that by specifying cascade deletes in the database you influenced the way the DataRelations for your dataset's DataTabless were inferred. How are you managing your datasets?

Sep 18, 2007 at 7:16 AM
I mean without specifying cascade delete in the database.

I have a strong typed dataset with both relation and foreign key constraint.
The update rule set to "cascade" in order to handle the primary keys that are set to identity in the database.
Right now are the delete rule and the reject/accept rule set to none.

Best regards
Sven Hasselblad