views:

80

answers:

1

I have the following VBScript, which is supposed to connect to a SQL Server 2005 database. But, my connection is failing. Why?

Set dbConnection = CreateObject("ADODB.Connection")

dbConnString = "Provider=SQLOLEDB.1;Data Source=srv\test1;" & _
               "Initial Catalog=tset_DB;user id ='abc';password='abc'"

'Open the connection
dbConnection.Open dbConnString
+1  A: 

You don't need quotations around your username and password. Try this:

Set dbConnection = CreateObject("ADODB.Connection")

dbConnString = "Provider=SQLOLEDB.1;Data Source=srv\test1;" & _
               "Initial Catalog=test_DB;user id =abc;password=abc"

'Open the connection
dbConnection.Open dbConnString

Also, your Initial Catalog was set to tset_DB, when I'm guessing it should be test_DB.

ConnectionStrings.com is a huge help for ensuring that your connection strings are valid.

Eric