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

I want to perform a recursive query in vb.net (MSSQL Server as Database). I found out how to do it in mssql (e.g. here: MSSQL Recursive Hierarchial Query[^]
), but how can I call it in vb.net?
My table looks like this:

ID Parent Name
---- ---- ----
1 Null A
2 1 B
3 1 C
4 3 D
...

So how can I get the IDs of every child element of a certain element?

Thanks
Posted

1 solution

C#
function get_id(int p_id)
{
   execut this line----
     -> "select id from table_name where parent="+p_id+"";

  it will return a result set
   in while loop access all its ids
  while(rs.next())
  {
     get_id(rs(0));// it is call to the parent function
  }
}

in this way we can get all child elements of a certain parent element
 
Share this answer
 
v2

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