Exact snippet from one of my programs :P
Code:
Try
Using conn As New MySqlConnection(GetConnectionInfo())
conn.Open()
If conn IsNot Nothing Then
If conn.State = ConnectionState.Open Then
conn.Close()
End If
End If
End Using
'MessageBox.Show("Your credentials have been verified, transferring now!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Asterisk)
Catch sqlerror As MySqlException
MessageBox.Show(sqlerror.Message, "An error occured", MessageBoxButtons.OK, MessageBoxIcon.Error)
Exit Sub
'Throw new Exception("An error occured while logging into the SQL server.", sqlerror);
End Try
FrmMain.Show()
Me.Close()
Then add the function
Code:
Public Function GetConnectionInfo() As String
Return ("Data Source=" + TxtHost.Text + ";uid=" + TxtUsername.Text + ";pwd=" + TxtPassword.Text + ";database=" + TxtWorld.Text + ";")
End Function
Of course you need to edit the code for your uses. OR you could google it :P http://www.google.com/search?hl=en&q...sql+connection