Koneksi MySql dengan Visual Basic DatagridView

Contoh koneksi ke Mysql DataBase dan menampilkan satu tabel ke DataGridView Visual Basic.


Contoh koneksi ke Mysql DataBase dan menampilkan satu tabel ke DataGridView Visual Basic.

Dim cmd As New MySql.Data.MySqlClient.MySqlCommand

Dim connect As New MySql.Data.MySqlClient.MySqlConnection("Database=test;Data Source=localhost;User Id=root")


cmd.CommandText = "SELECT * FROM `satu`"
cmd.Connection = connect

Dim Datanya As New DataTable
Dim da As New MySqlDataAdapter(cmd.commandtext, connect)
Dim cb As New MySqlCommandBuilder(da)

da.Fill(Datanya)

DataGridView1.DataSource = Datanya