Hey all,

I'm trying to have a ListBox show a list of tables available in a database. This can then be selected to be used later on.

My problem is getting the actual table name to show up. I have the connection to the mysql database working properly, but it just shows "System.Data.DataRowView"

Here is the code I have so far:

Dim con As New MySqlConnection
Dim theQuery As New MySqlCommand
Dim theTables As New DataTable
Dim theAdapter As New MySqlDataAdapter
Dim strTable As String

strTable = "SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA = 'm_fyp2011_n0218430';"

con.ConnectionString = frmLogin.strconn

con.Open()
theQuery.Connection = con
theQuery.CommandText = strTable
theAdapter.SelectCommand = theQuery
theAdapter.Fill(theTables)
lstTables.DataSource = theTables
con.Close()

Thanks in advance for any help :)

Recommended Answers

Set the DisplayMember of the listbox to "TableName"

lstTables.DisplayMember = "Table_Name"

Add that after line 16 of your post.

When you don't set the display member it uses the ToString of the object. Thats why you see what you are seeing.

Jump to Post

All 2 Replies

Member Avatar

Set the DisplayMember of the listbox to "TableName"

lstTables.DisplayMember = "Table_Name"

Add that after line 16 of your post.

When you don't set the display member it uses the ToString of the object. Thats why you see what you are seeing.

Ah, I feel like such a noob sometimes lol.

This works perfect, thank you very much :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.