Anda di halaman 1dari 3

Koneksi MySQL dengan VB.

Net
1. Software Conector.net versi 6.67
2. Tambahkan reference

3. Buat form 1

Imports MySql.Data.MySqlClient
Public Class Form1
Dim conn As MySqlConnection
Private Sub btnKoneksi_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnKoneksi.Click
conn = New MySqlConnection()
conn.ConnectionString = "server=localhost;user id=root;" & _
"password=;database=latihan"
Try
conn.Open()
MessageBox.Show("Koneksi Berhasil")
conn.Close()
Catch myerror As MySqlException
MessageBox.Show("Error Koneksi: " & myerror.Message)
Finally
conn.Dispose()
End Try
End Sub
End Class