Sekedar berbagi bagi yang belum tahu cara Koneksi Visual Basic Net dengan MySQL dengan mysql-connector-odbc 5.1, :
1. Download mysql-connector-odbc-5.1 disini
2. Buat sebuah modul beri nama KoneksiData dan masukan code beikut :
Module KoneksiData
Public KONEKSI As String
Public xSql As String
Public STATUS_Input As Boolean = False
Public CONN_odbc As New Odbc.OdbcConnection '/koneksi dg ODBC
Public CMD_odbc As New Odbc.OdbcCommand '/'perintah query (select,Insert, Delete, Update)
Public DTReader_odbc As Odbc.OdbcDataReader '/tempat menampung query
Public DTReader2_odbc As Odbc.OdbcDataReader '/tempat menampung query
Public DTAdapter_odbc As New Odbc.OdbcDataAdapter '/untuk DataGridView koneksi nya
Public DTtable_odbc As New DataTable '/untuk DataGridView datanya
Public BARIS_Edit As Integer
Dim ser, db, user, pass As String
Sub BUKA_MYSQL_dg_ODBC()
ser = "namaserver"
db = "namadatabase"
user = "namauser"
pass = "password"
Try
KONEKSI = "DRIVER={MySQL ODBC 5.1 Driver};SERVER=" & ser & ";DATABASE=" & db & ";UID=" & user & ";PWD=" & pass & ";port=3306;OPTION=2105"
CONN_odbc = New Odbc.OdbcConnection(KONEKSI)
CONN_odbc.Open()
Catch Salah As Exception
MessageBox.Show(Salah.Message, "Error Koneksi", MessageBoxButtons.OK, MessageBoxIcon.Error)
End
End Try
End Sub
End Module
1. Download mysql-connector-odbc-5.1 disini
2. Buat sebuah modul beri nama KoneksiData dan masukan code beikut :
Module KoneksiData
Public KONEKSI As String
Public xSql As String
Public STATUS_Input As Boolean = False
Public CONN_odbc As New Odbc.OdbcConnection '/koneksi dg ODBC
Public CMD_odbc As New Odbc.OdbcCommand '/'perintah query (select,Insert, Delete, Update)
Public DTReader_odbc As Odbc.OdbcDataReader '/tempat menampung query
Public DTReader2_odbc As Odbc.OdbcDataReader '/tempat menampung query
Public DTAdapter_odbc As New Odbc.OdbcDataAdapter '/untuk DataGridView koneksi nya
Public DTtable_odbc As New DataTable '/untuk DataGridView datanya
Public BARIS_Edit As Integer
Dim ser, db, user, pass As String
Sub BUKA_MYSQL_dg_ODBC()
ser = "namaserver"
db = "namadatabase"
user = "namauser"
pass = "password"
Try
KONEKSI = "DRIVER={MySQL ODBC 5.1 Driver};SERVER=" & ser & ";DATABASE=" & db & ";UID=" & user & ";PWD=" & pass & ";port=3306;OPTION=2105"
CONN_odbc = New Odbc.OdbcConnection(KONEKSI)
CONN_odbc.Open()
Catch Salah As Exception
MessageBox.Show(Salah.Message, "Error Koneksi", MessageBoxButtons.OK, MessageBoxIcon.Error)
End
End Try
End Sub
End Module