Imports MySql.Data.MySqlClient
Public Class Form1
Dim serverString As String = "Server=localhost;UserId=root;Password=1234;Database=1234"
Dim SQLConnection As MySqlConnection = New MySqlConnection
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
SQLConnection.ConnectionString = serverString
Try
If SQLConnection.State = ConnectionState.Closed Then
SQLConnection.Open()
MsgBox("Success")
Else
SQLConnection.Close()
MsgBox("no")
End If
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Private Sub SaveNames(ByRef SQLStatment As String)
Dim cmd As MySqlCommand = New MySqlCommand
With cmd
.CommandText = SQLStatment
.CommandType = CommandType.Text
.Connection = SQLConnection
.ExecuteNonQuery()
End With
SQLConnection.Close()
MsgBox("add")
SQLConnection.Dispose()
End Sub
End Class