|
-
Jan 19th, 2004, 08:45 PM
#1
Thread Starter
Addicted Member
[Resolved] SQL Relationships
Ok guys,
I'm sure there is an easy solution to this but I can't seem to find it.
Basically I am working with a large number of tables in a database with parent-child type relationships. (Enforced in both the Sql Database and the the datasets relationships)
For example
ParentTable
-ParentID
-ParentValue1
-ParentValue2
....
ChildTable
-ChildID
-ParentID
-ChildValue1
-ChildValue2
...
Now to insert isn't a problem, use a dataadapter on ParentTable and then on ChildTable. To delete you need to do it the other way round, ChildTable and then ParentTable. (As you cannot delete from ParentTable first due to childtable having a reference to one of it's rows.)
The problem is that there are alot more than 2 datatables in this relationship, also a datatable may have rows that are required to be added and deleted from it when an update is performed.
I have tried setting the SqlDatabase relationships to cascade deletions but .Net rightfully complains about a concurrency violation when it gets to a row that has already been deleted by Sql.
Any ideas on a clean way of resolving this?
Last edited by Carnifex; Jan 21st, 2004 at 05:43 AM.
-
Jan 19th, 2004, 10:58 PM
#2
Sleep mode
http://www.vbforums.com/showthread.p...hreadid=253655 , I don't know if you can figure things out of this !
-
Jan 19th, 2004, 11:10 PM
#3
Thread Starter
Addicted Member
Thanks for the response Pirate.
I already have the relations and everything going fine in my dataset.
My problem lies in the fact when performing an update command the order in which I update each table in the database matters depending on an insertion or deletion to/from the database. And when there are multiple insertions/deletions going on from the same table.
I think I may of figured out how to resolve this by using one of the overloaded update commands that works off a collection of datarows and using the DataTable.GetChanges() Method to get a collection of deleted datarows. I'll probably use this and perform 2 sweeps on the tables, first sweep for deletion, second for insertion/modification.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|