Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 338
  • Last Modified:

Loading MySQL table in a treeview/listview

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.

0
jphermans
Asked:
jphermans
  • 3
1 Solution
 
DhaestCommented:
Use ADO to list database tables and their records in a TreeView
http://www.vb-helper.com/howto_ado_tables_records_treeview.html

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(, , , _
            rs!TABLE_NAME)
        table_node.Tag = "Table"
        rs.MoveNext
    Loop
-->
Open a recordset with the data you want rs.open "select yourvalue from yourtable",...
Set table_node = trvData.Nodes.Add(, , , rs!field(0))
0
 
jphermansAuthor Commented:
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.
    tvwList.Nodes.Clear

    ' 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"
        rs.MoveNext
    Loop

    rs.Close
End Sub

My table calls Dvd .

Any idea why it's not working?

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

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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now