VB.Net Populate ComboBox With MySQL Data

How To Fill A Combobox From MySQL DataBase In VbNet

Fill ComboBox From MySQL DataBase In VB.Net

In This VB.Net Tutorial  We Will See How To Add Data From MySQL DataBase Into A Combobox Using DataTable In Visual Basic.Net Programming Language And Visual Studio Editor.


Project Source Code:

Imports MySql.Data.MySqlClient

Public Class Populate_Combobox_From_MySQL

    Private Sub Populate_Combobox_From_MySQL_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        Dim connection As New MySqlConnection("datasource=localhost;port=3306;username=root;password=")
        Dim adapter As New MySqlDataAdapter("SELECT `Id`, `FullName`, `Address`, `BirthDate` FROM s_t_d.student", connection)
        Dim table As New DataTable()

        adapter.Fill(table)

        ComboBox1.DataSource = table

        ComboBox1.ValueMember = "Id"
        ComboBox1.DisplayMember = "FullName"

    End Sub
End Class
      
///////////////OUTPUT:

VBNET Combobox With Data From MySQL




Share this

Related Posts

Previous
Next Post »

1 comments:

comments
3 mai 2021 à 01:55 delete

Hi! According to your project how can i Load fullname and Last Name into the Combobox?

Reply
avatar