Hi all,

I am trying to populate a TreeView using an Access database. I have been able to get the first set of braches in but I have not been able to completely get sub nodes in. The first node comes in just fine but each node to follow includes the nodes above it. So I know I am not closing my datasets right but I am not sure what I am doing wrong. Do you see what I am doing wrong?

Thanks Steve
Code:
        Dim MyAdapter As New OleDbDataAdapter
        Dim MyDataset As New DataSet
        Dim MyCommand As New OleDbCommand
        Dim MyRow As DataRow
        Dim MyNode As TreeNode

        Me.tvCodeLibrary.Nodes.Clear()

        MyCommand = New OleDbCommand("SELECT Name FROM CodeSection ORDER By Name", MyConnection)
        MyAdapter = New OleDbDataAdapter(MyCommand)
        MyAdapter.Fill(MyDataset, "CodeSection")
        For Each MyRow In MyDataset.Tables("CodeSection").Rows
            Me.tvCodeLibrary.Nodes.Add(MyRow(0))
        Next MyRow

        For Each MyNode In Me.tvCodeLibrary.Nodes

            MyCommand = New OleDbCommand("SELECT Name from Code where SectionID = (SELECT ID FROM CodeSection WHERE Name = '" & MyNodes.Text & "') ORDER BY Name", MyConnection)
            MyAdapter = New OleDbDataAdapter(MyCommand)
            MyAdapter.Fill(MyDataset, "Name")

            For Each MyRow In MyDataset.Tables("Name").Rows
                MyNode.Nodes.Add(MyRow(0))
            Next MyRow

        Next MyNode

        MyDataset.Dispose()
        MyAdapter.Dispose()
        MyCommand.Dispose()