≡ Menu

MyOLEDB Koneksi di vb.Net

‘ Declattion
Imports System.Data.OleDb

‘code

Private Sub btnConnect_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnConnect.Click
Dim Conn As OleDbConnection
Dim connStr As String
connStr = String.Format(“Provider=MySqlProv;” & _
“Location={0};Data Source={1};” & _
“User={2}; Password={3}”, _
txtServer.Text, txtDatabase.Text, _
txtUser.Text, txtPassword.Text)
Try
Conn = New OleDbConnection(connStr)
Conn.Open()
MsgBox(“Connected with ” + Conn.DataSource & _
Chr(10) + “Provider ” + Conn.Provider, _
MsgBoxStyle.Information, “Connected”)
Me.Text = “Connected with ” + Conn.DataSource
Catch ex As Exception
MsgBox(“Error to connecting : ” + ex.Message)
Finally
Conn.Close()
Conn.Dispose()
End Try
End Sub

{ 1 comment… add one }

Leave a Comment

*