How To Connect Vbnet To MySQL DataBase
In This VB.Net Tutorial We Will See How To Create A Connection Between MySQL DataBase And Visual Basic.Net Programming Language And How To Deconnect In Visual Studio Editor.
Project Source Code:
Imports MySql.Data.MySqlClient
Public Class Connect_To_MySQL
Dim connection As New MySqlConnection("datasource=localhost;port=3306;username=root;password=")
' button connect
Private Sub ButtonConnect_Click(sender As Object, e As EventArgs) Handles ButtonConnect.Click
Try
connection.Open()
Label1.Text = "connected"
Catch ex As Exception
MessageBox.Show(ex.ToString())
End Try
End Sub
' button deconnect
Private Sub ButtonDeconnect_Click(sender As Object, e As EventArgs) Handles ButtonDeconnect.Click
Try
connection.Close()
Label1.Text = "not connected"
Catch ex As Exception
MessageBox.Show(ex.ToString())
End Try
End Sub
End Class
///////////////OUTPUT:
1 comments:
commentshi admin , im trying connect to online sql but the connection require with SSL how to do with it ? i'm tried to add SslMode=Verify Full in the last string but it still not working
Reply