Start New Discussion within our Software Development Community

Hello, first post =D

Seemingly simple question, but I can't seem to find the solution.

(above were other SQL statements I had been fooling with)

SQL = "SHOW TABLES;"
        Try

            conn.Open()

            da = New MySqlDataAdapter(SQL, conn)


            Dim cb As MySqlCommandBuilder = New MySqlCommandBuilder(da)
            da.Fill(ds, "products")

            dgvMain.DataSource = ds
            dgvMain.DataMember = "products"

            'ComboBox1.DataSource = ds.Tables("products")
            'ComboBox1.DisplayMember = "products_model"

            ComboBox1.DataSource = ds.Tables("products")
            ComboBox1.DisplayMember = "Tables_in_my_database"

....

The remarked area works fine when I'm accessing a specific table. I've successfully inserted the products_model field into the combobox too.

The datagridview does show the table names in the db using the SHOW TABLES sql statment, but I'm not understanding how to get this info into the combobox instead.

Any ideas?

Thanks !

You can use something like -

Dim dt As New DataTable = DS.Tables(0)
    Dim dr As DataRow

For Each dr In dt.Rows()
       combo.Items.Add(dr("Description"))'What field data to add
    Next
    combo.SelectedIndex = -1
This question has already been answered. Start a new discussion instead.