I think maybe this is what you need:
The following code creates a SqlConnection object, sets the
SqlConnection.ConnectionString property, and opens the connection.
Public Sub ConnectToSql()
Dim conn As New SqlClient.SqlConnection
' TODO: Modify the connection string and include any
' additional required properties for your database.
conn.ConnectionString = & _
"integrated security=SSPI;data source=SQL Server Name;" & _
"persist security info=False;initial catalog=northwind"
' Insert code to process data.
Catch ex As Exception
MessageBox.Show("Failed to connect to data source")