Dim Conn As SqlConnection = New SqlConnection
Dim IP As String = "192.000.XXX.XXX"
Dim DBName As String = "Store"
Dim Username As String = "MyAdmin"
Dim Password As String = "password"
Try
Conn.Close()
With Conn
If .State = ConnectionState.Open Then .Close() : MsgBox("Can not connect to database server !") : Exit Sub
.ConnectionString = "Data Source=" & IP & ";Initial Catalog=" & DBName & ";Persist Security Info=True;User ID=" & Username & ";Password=" & Password & ""
.Open()
End With
Catch ex As Exception
MsgBox("Can not connect to database server !")
End Try
End Sub