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
  • And... what happens? Do you get an error? If so - post it - it'll make diagnosis a whole lot easier. Commented Aug 5, 2009 at 10:42

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.