473,326 Members | 2,813 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Populating a TreeView from a relational database

Let's say I have this db:

Table: Companies
-------
Ford
Toyota
BMW

Table: CarTypes
--------
Sedan
Van
Compact

Table: Colors
------
Red
Blue
Orange
Yellow
Green
Black

Table: Cars
----
ID Color Type Company
-- ----- ---- -------
1 Green Sedan Toyota
2 Red Sedan Toyota
3 Red Van Toyota
4 Blue Van Toyota
5 Blue Sedan Ford
6 Yellow Sedan Ford
7 Yellow Compact Ford
8 Orange Compact Ford
9 Black Sedan BMW

Color, Type and company are foreign keys

I want to represent that in a TreeView
Which will look like this:
Company
|
|-Toyota
| |-Sedan
| | |- Green
| | |- Red
| |-Van
| | |-Red
| | |-Blue
| |
|-Ford
| |-Sedan
| | |-Blue
| | |-Yellow
| |-Compact
| | |
| | |-Yellow
| | |-Orange
| |
|-BMW
| |-Sedan
| |-Black

Any ideas how to implement such thing?
Be as specific as you can

Thanks.

Nov 16 '05 #1
2 1646
i had to do something similar before and used this reference.

http://weblogs.asp.net/rosherove/arc...6/16/8726.aspx

Nov 16 '05 #2
I can think of several ways, which one is the best depends on several
factors.

Are you using MSSQL 2000? You could query FOR XML and then work with DOM.

Do you know how to create and work with DataRelations in DataSets? You could
reproduce the hierarchy in a DataSet first and then it's quite easy to fill
the TreeView.

HTH,
Alexander
<tz*****@gmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
Let's say I have this db:

Table: Companies
-------
Ford
Toyota
BMW

Table: CarTypes
--------
Sedan
Van
Compact

Table: Colors
------
Red
Blue
Orange
Yellow
Green
Black

Table: Cars
----
ID Color Type Company
-- ----- ---- -------
1 Green Sedan Toyota
2 Red Sedan Toyota
3 Red Van Toyota
4 Blue Van Toyota
5 Blue Sedan Ford
6 Yellow Sedan Ford
7 Yellow Compact Ford
8 Orange Compact Ford
9 Black Sedan BMW

Color, Type and company are foreign keys

I want to represent that in a TreeView
Which will look like this:
Company
|
|-Toyota
| |-Sedan
| | |- Green
| | |- Red
| |-Van
| | |-Red
| | |-Blue
| |
|-Ford
| |-Sedan
| | |-Blue
| | |-Yellow
| |-Compact
| | |
| | |-Yellow
| | |-Orange
| |
|-BMW
| |-Sedan
| |-Black

Any ideas how to implement such thing?
Be as specific as you can

Thanks.

Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: tzvikaz | last post by:
Let's say I have this db: Table: Companies ------- Ford Toyota BMW Table: CarTypes --------
0
by: serge calderara | last post by:
Dear all, I have an VB windows application that colect information form a remote database and then populate the tree view with part of the reords. As database data can be huge , I have used the...
0
by: imassadpk | last post by:
Hi all, Apprecite your help in resolving this tricky issue... I am trying implementing Recurrsive TreeView in MS. Access 2003 ADP project. So far, no luck :( The Problem: This sample...
2
by: Janus | last post by:
Hello. I need a little advice for populating the treeview control. I dont want my application to hang while populating the treeview, there is a lot of data what's the best approach? Maybe...
1
by: naijacoder naijacoder | last post by:
Hi Guys, I have an application below that is treeview menu populated from the database which works with asp.net webmatrix.But when i put it into code behind in Visual Studio.Net it gives the...
6
by: Jan Krouwer | last post by:
I have a treeview which is populated from a relational database. In order to copy part of the tree, I need to add to the database the relationship of the part of the tree to be copied but with new...
5
by: Brian Henry | last post by:
I need a way to give each node an id number onto of what the text is being displayed so i can access data in a database... how would i do this? this is an example RootNode (data: root) + Child1...
0
by: drop | last post by:
Hi, I'm currently working with the Treeview control in ASP .Net 2.0. The tree is filled dynamically based on data contained in a MySQL Database. Here is the exact behavior I want : 1 - User...
2
by: Steve Arndt | last post by:
I'm trying to populate a vb.net treeview using a SQLDataReader at Treeview1_BeforeExpand. Basically I have a Treeview with 5 parent nodes and 1 dummy child node per parent. The first parent node...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.