Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Popuating a treeview

Author  Topic 

kirknew2SQL
Posting Yak Master

194 Posts

Posted - 2007-10-17 : 14:28:36
If this is not the right place to ask this question maybe some one can direct me to a URL

I have a SQL 2005 table containing this data. I need to use this data to populate a Windows form tree view. Does any one have or know where i can find some code that will do this?

The unusual thing is a child may be it's own parent. See 15.

I have not been ablr to find anythibng and I am at a complete loss. Any help you can give would be greatly appreciated.

Thank you

Child...Parent...Depth.....Hierarchy
1.........NULL.....0..........01
2..........1.......1..........01.02
5..........2.......2..........01.02.05
6..........2.......2..........01.02.06
3..........1.......1..........01.03
7..........3.......2..........01.03.07
11.........7.......3..........01.03.07.11
14.........11......4..........01.03.07.11.14
12.........7.......3..........01.03.07.12
13.........7.......3..........01.03.07.13
8..........3.......2..........01.03.08
9..........3.......2..........01.03.09
4..........1.......1..........01.04
10.........4.......2..........01.04.10
15.........NULL....0..........15
15.........15......1..........15.15
16.........15......1..........15.16
18.........16......2..........15.16.18
17.........15......1..........15.17

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2007-10-17 : 15:02:04
You should probably have posted this question in the Transact SQL 2000/2005 forum but nevertheless you'll find some pretty good info by searching for "tree" in the google-search in the top right corner of the website or maybe by looking here, the bottom of the article seems to suit your needs quite good: http://www.sqlteam.com/article/more-trees-hierarchies-in-sql

--
Lumbago
"Real programmers don't document, if it was hard to write it should be hard to understand"
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-10-17 : 16:11:37
moved from script library.

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
SSMS Add-in that does a few things: www.ssmstoolspack.com
Go to Top of Page

kirknew2SQL
Posting Yak Master

194 Posts

Posted - 2007-10-17 : 18:34:50
The URL http://www.sqlteam.com/article/more-trees-hierarchies-in-sql is a good artical showing how to set up and populate the table. But not how to put the data into a tree view.

Any one have any suggestions how to populate a treeview given the data in the original post?
Go to Top of Page
   

- Advertisement -