fishsqzr
Programmer
- Oct 23, 2007
- 1
I'm using a Designer-generated typed dataset with several master:detail levels. I've already discovered I must either set EnforceConstraints to false or change the load order of the tables (from what Designer generates) or I will get constraint conflicts. Now I am trying to discover how to delete related child records when a master record is deleted. When I delete the master record in a grid, the master gets deleted from the DataSet OK and the children apparently get deleted as well, but when I click the Update button in the Designer-generated BindingNavigator I again get constraint conflicts. Turning off EnforceConstraints does not help here, so I assume the database itself is complaing because updates are not being applied in the correct order.
I tried editing the DataSet's xsd file to edit the relations to include Constraints and Relations, with Cascade on both the Update rule and the Delete rule, but that didn't help. I discovered I could get the deletion to work so long as I alter the Designer code to update the child tables first. That also makes it likely that the problem is happening at the database level. However, if I use that approach and then add a new master record and some child records before updating, the constraints are violated again unless I update the master table before the child table (in direct conflict with the delete tactic). If some records have been added and some have been deleted, I assume all Hell will break loose.
I can write code to make all of the Add/Change/Delete events work, but the only sure way to do so is apply updates one at a time as soon as they happen. That makes the usefullness of a disconnected dataset a bit questionable.
Am I missing something, or is ADO.NET missing something? I'm beginning to think this system is a bit too disconnected from the underlying data. Other tools I have used would handle all update operations automatically after I define the tables, relationships and constraints. I find it hard to believe that ADO.NET does not have some way to handle these relationships properly as well. Any guidance would be greatly appreciated.
I tried editing the DataSet's xsd file to edit the relations to include Constraints and Relations, with Cascade on both the Update rule and the Delete rule, but that didn't help. I discovered I could get the deletion to work so long as I alter the Designer code to update the child tables first. That also makes it likely that the problem is happening at the database level. However, if I use that approach and then add a new master record and some child records before updating, the constraints are violated again unless I update the master table before the child table (in direct conflict with the delete tactic). If some records have been added and some have been deleted, I assume all Hell will break loose.
I can write code to make all of the Add/Change/Delete events work, but the only sure way to do so is apply updates one at a time as soon as they happen. That makes the usefullness of a disconnected dataset a bit questionable.
Am I missing something, or is ADO.NET missing something? I'm beginning to think this system is a bit too disconnected from the underlying data. Other tools I have used would handle all update operations automatically after I define the tables, relationships and constraints. I find it hard to believe that ADO.NET does not have some way to handle these relationships properly as well. Any guidance would be greatly appreciated.