ASP递归调用:已知节点查找根节点的函数

 

1 Function getTreeRootId(pNodeId)
2 getSQL = "select note_id,parent_id from [T_tree_demo] where note_id='"& pNodeId &"'"
3 Set getRs = db.Execute(getSQL)
4 If Not getRs.eof Then
5 If Trim(getRs("parent_id")) = "0" Then
6 getTreeRootId = Trim(getRs("note_id"))
7 Exit Function
8 Else
9 getTreeRootId = getTreeRootId(Trim(getRs("parent_id")))
10 End If
11 Else
12 getTreeRootId = 0
13 Exit Function
14 End If
15 getRs.close
16 Set getRs = Nothing
17  End Function
18  

 

posted @ 2009-12-03 14:44  笑天.net  阅读(353)  评论(0编辑  收藏  举报