fishsqzr 0 Junior Poster in Training

I'm using a typed dataset with several master:detail levels. I've already discovered I must set EnforceConstraints to false to load the data or I will get constraint conflicts. Now I am trying to discover how to delete related child records when a master record is deleted. The master gets deleted from the dataset OK and the children apparently get deleted as well (see below).

When I try to save the updates, I get a constraint conflict. Turning off EnforceConstraints does not help here, so I assume the database itself is complaing.

I tried editing the xsd file to set 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 update the child table 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 of all types of updates to all tables 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? Other tools I have used would handle these problems automatically as soon as 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, and I suspect I am not setting up right.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.