Click here to Skip to main content
15,887,349 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
VB
Private Sub Form_Activate()
    Dim nodX As Node
    Set nodX = TreeView1.Nodes.Add(, , "root", "Chart")
    Set nodX = TreeView1.Nodes.Add("root", tvwChild, "child1", "Details")

    Set RS1  = New ADODB.Recordset
    RS1.Open "SELECT * FROM CHACCOUNT WHERE LEVELNO=1", CON, adOpenKeyset, adLockOptimistic
    If RS1.RecordCount > 0 Then
        Dim C
        C = 1
        RS1.MoveFirst
        Do Until RS1.EOF
            Set nodX = TreeView1.Nodes.Add("child1", tvwChild, "child1-" & C & RS1!CODE, RS1!BUYER_NAME)
            Set RS2  = New ADODB.Recordset
            RS2.Open "SELECT * FROM CHACCOUNT WHERE LEVELNO=2", CON, adOpenKeyset, adLockPessimistic
            If RS2.RecordCount > 0 Then
                Dim D
                D = 1
                RS2.MoveFirst
                Do Until RS2.EOF
                    Set nodX = TreeView1.Nodes.Add("child1-" & C & RS1!CODE, tvwChild, "child1-" & C & "-" & D & RS2!CODE, RS2!BUYER_NAME)
                    Set RS3  = New ADODB.Recordset
                    RS3.Open "SELECT * FROM CHACCOUNT WHERE LEVELNO=3", CON, adOpenKeyset, adLockOptimistic
                    If RS3.RecordCount > 0 Then
                        Dim E
                        E = 1 
                        RS3.MoveFirst
                        Do Until RS3.EOF
                            Set nodX = TreeView1.Nodes.Add("child1-" & C & "-" & D & RS2!CODE, tvwChild, "child1-" & C & "-" & D & "-" & E & RS3!CODE, RS3!BUYER_NAME)
                            Set RS4  = New ADODB.Recordset
                            RS4.Open "SELECT * FROM CHACCOUNT WHERE LEVELNO=4", CON, adOpenKeyset, adLockOptimistic
                            If RS4.RecordCount > 0 Then
                                Dim F
                                F = 1
                                RS4.MoveFirst
                                Do Until RS4.EOF
                                    Set nodX = TreeView1.Nodes.Add("child1-" & C & "-" & D & "-" & E & RS3!CODE, tvwChild, "child1-" & C & "-" & D & "-" & E & "-" & F & RS4!CODE, RS4!BUYER_NAME)
                                    F = F + 1
                                    RS4.MoveNext
                                Loop
                            End If
                            RS4.Close
                            Set RS4 = Nothing
                            E = E + 1
                            RS3.MoveNext
                        Loop
                    End If
                    RS3.Close
                    Set RS3 = Nothing
                    D = D + 1
                    RS2.MoveNext
                Loop
            End If
            RS2.Close
            Set RS2 = Nothing
            C = C + 1
            RS1.MoveNext
        Loop
    End If
    RS1.Close
    Set RS1 = Nothing
End Sub
Posted
Updated 12-Aug-11 1:30am
v2
Comments
shakil aima 12-Aug-11 7:27am    
i load data from database parent not specify his child plz help me in this prjoect
Philippe Mori 12-Aug-11 9:23am    
Without explaining what you expect your code to do, you won't merit much points for your question...

Run it under the debugger. Whatever your problem is will be revealed as you step through the code.
 
Share this answer
 
Did you write the original code. If yes, I think you should look at refactoring it.

This is a virtual nightmare to maintain.
You are getting an error somewhere, but you cannot find it.

Think of how difficult it would be for someone else to debug and find the same error.
 
Share this answer
 
Comments
#realJSOP 12-Aug-11 7:53am    
I was gonna mention that, but I wasn't sure I could do it without showing obvious disdain for all things VB. :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900