Click here to Skip to main content
15,906,816 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am doing web application in that I used treeview control. I already bind the values to tree node.
I am having table like given below.

UniqueID NormalisedId ParentNormaliseId(Parent Node)
1 1 0 -(Root Node level 1)
2 2 1 -(Root Node level 2)
3 3 2
4 4 3
5 5 1 -(Root Node level 2)


in above case 1 is parent node now if i select node which is 1 then i want to delete all the child node i.e. 2,3,4

The level can be increase to n

How can I do this using recursive function or any query for the same



Thanks,
sjs
Posted
Updated 18-Aug-11 23:25pm
v2

1 solution

The easiest way is to create a self referring foreign key from ParentNormaliseId to NormalisedId (or UniqueID as the case may be) with the CASCADE DELETE option. And then when you delete the parent row, all child rows will be deleted automatically.
 
Share this answer
 
Comments
sjs4u 19-Aug-11 5:41am    
can you give me example in the above case or do you have any link for the same?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900