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

theQuery.Connection = con
theQuery.CommandText = strTable
theAdapter.SelectCommand = theQuery
lstTables.DataSource = theTables

Thanks in advance for any help :)

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 :)

This question has already been answered. Start a new discussion instead.