TreeView Questions

  • Thread starter Thread starter rhaazy
  • Start date Start date
R

rhaazy

Using VS2003 form.Treeview class

I need to populate a treeview using three tables in my database.

tblOrgSystems looks like this:

OrgSystemID OrgSystem
1 N. America
2 Canada


tblOrgSystemNodes looks like this:

OrgSystemID OrgNode ID OrgNode
1 3 Manistique
1 4 Houston
1 7 M.Sales
1 8 M.IT
1 9 M.HR
1 10 H.Sales
1 11 H.IT
1 12 H.HR
2 5 Toronto
2 6 Ontario
2 13 T.Sales
etc.....

tblOrgSystemNodeParent looks like this:

OrgSystemID OrgNodeID OrgNodeParentID
1 1 1
1 3 1
1 4 1
1 7 3
1 8 3
1 9 3
2 2 2
2 5 2
2 6 2
2 13 5
2 14 5
2 15 5
etc......

My root nodes are the OrgSystems, that part is easy. But my second
select statement must populate nodes based on this parent child
relationship. It should look at the OrgNodeID of the parent node and
know what to populate it with based on the info in
tblOrgSystemNodeParent. So far this is what I have for a select
statement, I know I'm on the right track but I'm missing something, any
help would be great.

string select = "select OrgNode, tblOrgSystemNode.OrgNodeID from
tblOrgSystemNode JOIN tblOrgSystemNodeParent ON
tblOrgSystemNode.OrgNodeID = tblOrgSystemNodeParent.OrgNodeID where
tblOrgSystemNodeParent.OrgNodeParentID = '" +
OrgSystemID[treeView1.SelectedNode.Index] + "'";
 
See an article I wrote in April 2006 from http://emoreau.s2i.com/

You will find that I open 2 distinct datatables and I set relations between
them.

--


HTH

Éric Moreau, MCSD, Visual Developer - Visual Basic MVP
Conseiller Principal / Senior Consultant
S2i web inc. (www.s2i.com)
http://emoreau.s2i.com/

rhaazy said:
Using VS2003 form.Treeview class

I need to populate a treeview using three tables in my database.

tblOrgSystems looks like this:

OrgSystemID OrgSystem
1 N. America
2 Canada


tblOrgSystemNodes looks like this:

OrgSystemID OrgNode ID OrgNode
1 3 Manistique
1 4 Houston
1 7 M.Sales
1 8 M.IT
1 9 M.HR
1 10 H.Sales
1 11 H.IT
1 12 H.HR
2 5 Toronto
2 6 Ontario
2 13 T.Sales
etc.....

tblOrgSystemNodeParent looks like this:

OrgSystemID OrgNodeID OrgNodeParentID
1 1 1
1 3 1
1 4 1
1 7 3
1 8 3
1 9 3
2 2 2
2 5 2
2 6 2
2 13 5
2 14 5
2 15 5
etc......

My root nodes are the OrgSystems, that part is easy. But my second
select statement must populate nodes based on this parent child
relationship. It should look at the OrgNodeID of the parent node and
know what to populate it with based on the info in
tblOrgSystemNodeParent. So far this is what I have for a select
statement, I know I'm on the right track but I'm missing something, any
help would be great.

string select = "select OrgNode, tblOrgSystemNode.OrgNodeID from
tblOrgSystemNode JOIN tblOrgSystemNodeParent ON
tblOrgSystemNode.OrgNodeID = tblOrgSystemNodeParent.OrgNodeID where
tblOrgSystemNodeParent.OrgNodeParentID = '" +
OrgSystemID[treeView1.SelectedNode.Index] + "'";
 
Back
Top