Advertisement
Guest User

Untitled

a guest
Aug 9th, 2015
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Imports MySql.Data.MySqlClient
  2. Public Class Form1
  3.     Public conn As New MySqlConnection
  4.     Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  5.         connect()
  6.  
  7.     End Sub
  8.  
  9.     Public Sub connect()
  10.         Dim DatabaseName As String = "afrdb"
  11.         Dim server As String = "localhost"
  12.         Dim userName As String = "root"
  13.         Dim password As String = "root"
  14.         If Not conn Is Nothing Then conn.Close()
  15.         conn.ConnectionString = String.Format("server={0}; user id={1}; password={2}; database={3}; pooling=false", server, userName, password, DatabaseName)
  16.         Try
  17.             conn.Open()
  18.  
  19.             MsgBox("Connected")
  20.         Catch ex As Exception
  21.             MsgBox(ex.Message)
  22.         End Try
  23.         conn.Close()
  24.     End Sub
  25. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement