Sub ConnectToSQL_SQLOLEDB()
Dim conn As ADODB.Connection
Set conn = New ADODB.Connection
With conn
.Provider = "SQLOLEDB"
.ConnectionString = "Data Source=mySource;" & _
"database=yourDatabase; UserId=sa; Password=;"
.Open
End With
If conn.State = adStateOpen Then
Debug.Print "Connection was established."
End If
conn.Close
Set conn = Nothing
End Sub