Connection String for SQL:
Conn_String = “Provider=SQLOLEDB.1;Initial Catalog=” & strDB & “;Data Source=” & strServer & “;Network Library=DBMSSOCN;User Id=” & strUser & “;PASSWORD=” & strPwd & “;”
strDB is the name of the database, strServer is the name of SQLServer, strUser is the user id, and strPwd is the password.
Once you get the connection string, you can open the connection as follows:
Dim cn As New ADODB.Connection
cn.ConnectionString = Conn_String