How to get MySQL Table list to Combo box in VB.Net

On this tutorial, I am going to show you how to retrieve or get the table list in a MySQL Database using Visual Basic.Net. It is pretty easy to get the table list to a combo box in VB.Net. First, we need to create a module to connect to the MySQL Database. This tutorial gives you a quick way to create a MySQL Connection module.

OK lets get started

Private Sub Frm_QueryData_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim cmd As New MySqlCommand("SHOW TABLES", conn)
        Dim dr As MySqlDataReader
        Try
            MySQLConnect.Connect() 'MySQLConnect is my MySQL Module
            dr = cmd.ExecuteReader
            Do While dr.Read
                cboTable.Items.Add(dr.GetString(0))
            Loop
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Critical)
        End Try

    End Sub

My Form design

get table list to combo box

When my program runs:

get mysql table in vb.net

Admin

Leave a Reply

Your email address will not be published. Required fields are marked *