How To Fill A ListBox From MySQL DataBase In VbNet
In This VB.Net Tutorial We Will See How To Add Data From MySQL DataBase Into A ListBox Using DataTable In Visual Basic.Net Programming Language And Visual Studio Editor.
Project Source Code:
Imports MySql.Data.MySqlClient
Public Class Populate_ListBox_From_MySQL
Private Sub Populate_ListBox_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)
ListBox1.DataSource = table
ListBox1.ValueMember = "Id"
ListBox1.DisplayMember = "FullName"
End Sub
End Class
///////////////OUTPUT: