Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports MySql.Data.MySqlClient
- Public Class Form1
- Public conn As New MySqlConnection
- Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
- connect()
- End Sub
- Public Sub connect()
- Dim DatabaseName As String = "afrdb"
- Dim server As String = "localhost"
- Dim userName As String = "root"
- Dim password As String = "root"
- If Not conn Is Nothing Then conn.Close()
- conn.ConnectionString = String.Format("server={0}; user id={1}; password={2}; database={3}; pooling=false", server, userName, password, DatabaseName)
- Try
- conn.Open()
- MsgBox("Connected")
- Catch ex As Exception
- MsgBox(ex.Message)
- End Try
- conn.Close()
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement