Ecco una funzione per ricostruire ricorsivamente la gerarchia di valori ID:
codice:
<%
function getParentPathByID(cn, valueID, cnt, byRef outArray)
if len(valueID) = 0 or not isNumeric(valueID) then valueID = 0
s = "SELECT parentID FROM tblNodes WHERE nodeID = " & valueID
set r = cn.execute(s)
if not r.eof then
reDim preserve outArray(cnt)
parentValueID = r("parentID")
outArray(cnt) = parentValueID
if not parentValueID = 0 then
cnt = cnt + 1
getParentPathByID cn, parentValueID, cnt, outArray
end if
end if
r.close
set r = nothing
end function
ID = request.queryString("ID")
if len(ID) = 0 or (not isNumeric(ID) then ID = 0
set conn = ...
conn.open ...
%>
» Homepage
<%
dim arrID()
getParentPathByID conn, ID, 0, arrID
if isArray(arrID) then
for i = uBound(arrID) to lBound(arrID) step -1
sql = "SELECT * FROM tblNodes WHERE nodeID = " & arrID(i) set rs = conn.execute(sql)
if not rs.eof then
%>
» <%=campoNome%>
<%
end if
rs.close
set rs = nothing
next
end if
if ID > 0 then
sql = "SELECT * FROM tblNodes WHERE nodeID = " & ID set rs = conn.execute(sql)
if not rs.eof then
%>
» <%=rs("nodeName")%>
<%
end if
rs.close
set rs = nothing
end if
conn.close
set conn = nothing
%>