467,921 Members | 1,336 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,921 developers. It's quick & easy.

ado parent/child scenario advice needed

Hi. I have an ecommerce application that has a shopping cart as many do.
I've created a way to automatically add other items to the cart if
certain items are added, like "Get a fee t-shirt if you buy this" kind
of stuff.
The DataTable that holds the cart items has a column for "ID" (primary
key) and parentID that references another item's ID for items added with
another, so they can be lumped together. This lets me delete both the
main item and the free t-shirt item if the main item is deleted.
The method I have to do this is pretty crude:

I in a DataTable DeleteCommand, I just create a dataview to find the
child items with a RowFilter: "parentID = " & e.Item.ItemIndex("ID") and
delete those too.

This has worked for a while, but a client was making an item that would
add another item that would add another item. So there is now a
recursive relationship and my delete logic fails leaving "orphaned"
items that have a parentID, but the parent item is gone. This violates
the business rules (no free t-shirt without qualifying item).

So is there a best practice for this kind of thing? I played with
DataRelations a little, but I always wound up violating constraints if I
added an item with no child. Maybe I'm just doing it wrong, but if
anyone has a suggestion or can point me to a good link that illustrated
a recursive delete from a datatable, I would certainly appreciate it.
Hope this made sense. Thanks!

Apr 10 '06 #1
  • viewed: 774

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Kelmen Wong | last post: by
reply views Thread by Karthick Kumar | last post: by
reply views Thread by Chris Waldmann via .NET 247 | last post: by
3 posts views Thread by Maheshkumar.R | last post: by
6 posts views Thread by Edwinah63 | last post: by
reply views Thread by Innova | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.