Try this out,
Step 1.
Dim strCon as string
Dim con as new ADODB.Connection
Step 2.
if you are using a DSN(Data source name) to connect to the SQL server, Then use this method
Syntax:
strCon="DSN=DSN_Name;UID=userID;PWD=password;Database=databasename"
Or you can use this method which is much easier,
Syntax:
strCon="DRIVER={SQL SERVER};SERVER=SERVER_Name;UID=userID;PWD=password;Database=databa"