|
<%@ Language="VBScript" %>
<%
' Response.Expires = 0
Const CONN_STRING = "Provider=microsoft.jet.oledb.4.0;data source=D:\WebSites\figment.ca\Database\Inventory Control.mdb"
Dim oConn, oRec, oTree, HTML
Set oConn = Server.CreateObject("ADODB.Connection")
oConn.ConnectionString = CONN_STRING
oConn.Open
Set oRec = Server.CreateObject("ADODB.Recordset")
'####################################################################################
Function BuildTree(piParentKey)
'##Build Tree -- Builds each node recursively.
Dim poRec, psSQL, psParentID, psNodeID, psHTML, pbExpand, psImage
Set poRec = Server.CreateObject("ADODB.Recordset")
'Build query to extract data from the database for this parent
psSQL = "SELECT * FROM Categories WHERE NAV_PARENT = "& piParentKey &" ORDER BY NAV_ORDER"
poRec.Open psSQL, oConn, 0, 3
If Not (poRec.EOF and poRec.BOF) Then
'## Loop through each Record in this Recordset
'## If there are no child nodes for the parent node of this tree, then this loop
'## will not run.
Do While Not poRec.EOF
'## Create node information for this record
psNodeID = "B" & poRec("NAV_PKEY")
psParentID = "B" & poRec("NAV_PARENT")
psHTML = " " & poRec("NAV_TITLE") & ""
' psHTML = " " & poRec("NAV_TITLE") & ""
' psHTML = " "& poRec("NAV_TITLE") & ""
pbExpand = poRec("NAV_DEFAULT_STATE")
psImage = poRec("NAV_IMAGE")
oTree.Add psParentID, psNodeID, psHTML, pbExpand, psImage
'## Build tree for child nodes of this parent
BuildTree poRec("NAV_PKEY")
poRec.MoveNext
Loop
End If
poRec.Close
Set poRec = Nothing
End Function
'####################################################################################
Set oTree = Server.CreateObject("obout_ASPTreeView_XP.Tree")
html = " Products and Services"
oTree.Add "root", "B23", html, True
'## Build tree
BuildTree 23
' html = " Order Online!"
' oTree.Add "root", "H0", html, False, "shoprite.gif"
'## Find selected node
If Len(Request.QueryString("catid")) > 0 Then
oTree.SelectedNode_Id = "B"& Request.QueryString("catid")
Else
oTree.SelectedNode_Id = "B23"
End If
Response.Write oTree.HTML
Set oTree = Nothing
Set oRec = Nothing
Set oConn = Nothing
%> |