# 附上 Recursive 的程式码

Posted by Sephiroth on June 10, 1999 at 11:20:05:

In Reply to: 如何找出某一 Node 的所有后代子孙? posted by Sephiroth on June 10, 1999 at 10:32:08:

Private Sub RecursiveFind(lngID As Long)
Dim oRs As ADODB.Recordset
Dim sTSQL As String
Dim lIndex As Long, lCount As Long
Dim lRet As Long
Set oRs = New ADODB.Recordset
sTSQL = "SELECT * FROM Relationship WHERE ID=" & lngID
Set oRs = mobjCon.Execute(sTSQL)
lCount = oRs.RecordCount
If lCount Then
For lIndex = 1 To lCount
Debug.Print oRs("ID"), oRs("ChildID")
RecursiveFind oRs("ChildID")
oRs.MoveNext
Next
End If
End Sub

Follow Ups: