Loading MySQL table in a treeview/listview

Posted on 2005-04-06
Last Modified: 2008-02-01
I've created an dvd collection database in MySQL.
Now i'm writing a interface for the db and since i'm newbie in
vb and programming i don't know how to do the following:

I've a table for category (horror, comedy,...).
If the form loads then a want that the table shows up in the treeview as main nodes en when
i click a category the titles are in the listview.
Is it possible to do this and can someone give me a sample code ?

Thank you.

Question by:jphermans
    LVL 53

    Expert Comment

    LVL 53

    Expert Comment

    Use ADO to list database tables and their records in a TreeView

    You'll need to change one little thing:
    Set rs = m_Conn.OpenSchema(adSchemaTables, _
            Array(Empty, Empty, Empty, "Table"))
        Do While Not rs.EOF
            Set table_node = trvData.Nodes.Add(, , , _
            table_node.Tag = "Table"
    Open a recordset with the data you want "select yourvalue from yourtable",...
    Set table_node = trvData.Nodes.Add(, , , rs!field(0))

    Author Comment

    I don't get the table in the treeview.
    Here is my code:

    ' List the tables in the database.
    Private Sub ListTables()
    Dim rs As ADODB.Recordset
    Dim table_node As Node

        ' Clear the TreeView.

        ' Use OpenSchema and get the table names.
        ' The final argument in the parameter array
        ' is "Table" to indicate we want a list of tables.
        Set rs = conn.OpenSchema(adSchemaTables, _
            Array(Empty, Empty, Empty, "Table"))
        Do While Not rs.EOF
            Set table_node = tvwList.Nodes.Add(, , , rs!Dvd(0))
            table_node.Tag = "Table"

    End Sub

    My table calls Dvd .

    Any idea why it's not working?

    LVL 53

    Accepted Solution

    What do you want in your treeview ? A column from your table ?

    dim rs as adodb.recordset
    set rs = new adodb.recordset "select yourcolumn from DVD", conn
        Do While Not rs.EOF
            Set table_node = tvwList.Nodes.Add(, , , rs!yourColumn)
            table_node.Tag = "Table"

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
    Introduction In a recent article ( for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
    Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now