I URGENTLY require a recursive database search routine 
Author Message
 I URGENTLY require a recursive database search routine

Is a recusive routine really needed?

If the two items are displayed in order, why not just retrieve them
that way, i.e, add Order by [parent][name]  to the Sql.

Then process the record set from top down, tracking when the parent
value changes tells you when indent a record a level or keep it at the
top level.

Maybe I missed something, seems a lot easier and faster than doing a
recursive search.



Sun, 24 May 1998 03:00:00 GMT  
 I URGENTLY require a recursive database search routine

Quote:
>I have a database with parent and name fields, and I want to create a
>hierarchy from these two fields in Treeview. If the parent field is
>null, then that "node" will be the root.

>The best way I can think of doing this is by writing some sort of
>recursive routine to search the database for the parent and name
>fields any "name" can only have one parent and hence is unique, but a
>"parent" can have many children.

>E.g Search database for "name" where "parent" = ""  - make this the
>root node called "name".
>Then search database for "name" where "parent" = name of root node -
>make these children of the root node....etc etc

>Any help would be most appreciated. Thanks.

    I did something like this once.  Fortunately, my database table would
hold a small enough number of items that I could select all rows and load
them into an array.  I then recursively passed through the array until I
had my tree loaded.

    Cordially,
    Bob Moss



Sun, 24 May 1998 03:00:00 GMT  
 I URGENTLY require a recursive database search routine
I have a database with parent and name fields, and I want to create a
hierarchy from these two fields in Treeview. If the parent field is
null, then that "node" will be the root.

The best way I can think of doing this is by writing some sort of
recursive routine to search the database for the parent and name
fields any "name" can only have one parent and hence is unique, but a
"parent" can have many children.

E.g Search database for "name" where "parent" = ""  - make this the
root node called "name".
Then search database for "name" where "parent" = name of root node -
make these children of the root node....etc etc

Any help would be most appreciated. Thanks.



Sun, 24 May 1998 03:00:00 GMT  
 I URGENTLY require a recursive database search routine

Quote:
>I have a database with parent and name fields, and I want to create a
>hierarchy from these two fields in Treeview. If the parent field is
>null, then that "node" will be the root.
>The best way I can think of doing this is by writing some sort of
>recursive routine to search the database for the parent and name
>fields any "name" can only have one parent and hence is unique, but a
>"parent" can have many children.
>E.g Search database for "name" where "parent" = ""  - make this the
>root node called "name".
>Then search database for "name" where "parent" = name of root node -
>make these children of the root node....etc etc
>Any help would be most appreciated. Thanks.

It's OK I have written one....

Sub AddChildren(Name As String)
    Dim NewSearch As Recordset
     Dim NewNode As Node
    Dim SQL As String, ParentOD As String, NewName As String
    Dim I As Integer

    SQL = "SELECT * FROM OD WHERE Owning_OD = '" & Name & "'"
    Set NewSearch = Dbs.OpenRecordset(SQL, dbOpenDynaset)
    If NewSearch.RecordCount = 0 Then
    'Exit Sub
    Else
    NewSearch.MoveNext
    Do While Not NewSearch.EOF
    ParentOD = NewSearch!OWNING_OD
    NewName = NewSearch!OD_NAME
    Set NewNode = Treeview1.Nodes.Add(ParentOD, tvwChild, NewName,
NewName, "node")
    NewNode.ExpandedImage = "open"
    AddChildren (NewName)
    NewSearch.MoveNext
    Loop
    End If
End Sub

Thanks if you were working on it.



Sun, 24 May 1998 03:00:00 GMT  
 I URGENTLY require a recursive database search routine

Quote:

>Subject: I URGENTLY require a recursive database search routine
>Date: Wed, 06 Dec 1995 11:28:58 GMT
>I have a database with parent and name fields, and I want to create a
>hierarchy from these two fields in Treeview. If the parent field is
>null, then that "node" will be the root.

try something like this. This will take parents and child from a table "Group"
and inset them into table "Dummy Tree"

    Db.Execute ("DELETE * FROM [Dummy Tree]")
    Set Dt = Db.OpenTable("Dummy Tree")
    Dt.AddNew
    Dt("Child_ID") = ID
    Dt("Parent_ID") = 0
    Dt.Update
    Dt.MoveLast
    Do Until Dt.EOF
      Db.Execute( "INSERT INTO [Dummy Tree] Parent_ID, Child_ID SELECT
         DISTINCTROW " & Dt("Child_ID") & " AS EXPR1, Child_ID  FROM Group
         WHERE Parent_ID =" & Dt("Child_ID"))  
     Dt.MoveNext      
     Loop    
     Dt.Close

Antti Kilpinen



Mon, 25 May 1998 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Recursive database searches

2. VB5 - Database search routine ?

3. database search routine

4. Need recursive copy routine (Like XCopy)

5. Retaining values in a recursive routine...

6. Recursive Dir Function required

7. VISUAL BASIC DEVELOPERS URGENTLY REQUIRED

8. Visual Basic Professionals urgently required

9. VB UDF Required Urgently

10. Help Urgently Required

11. VISUAL BASIC DEVELOPERS URGENTLY REQUIRED

12. Digital filter for VB urgently required

 

 
Powered by phpBB® Forum Software