0

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

2
Contributors
2
Replies
4
Views
5 Years
Discussion Span
Last Post by Wolxhound90
1

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.

0

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.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.