VB.Net Connect To MySQL

How To Connect Vbnet To MySQL DataBase 

connect vb.net to mysql

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:





Connect VBNet To MySQL DataBase

Close MySQL Database Connection With VB.Net




Share this

Related Posts

Previous
Next Post »

1 comments:

comments
19 juin 2023 à 00:20 delete

hi 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
avatar