Showing results for 
Search instead for 
Did you mean: 

Database connection to MS SQL Server 2008 R2

New Contributor

Database connection to MS SQL Server 2008 R2

Hi, I am trying to connect to SQL using my local maching through scripting. However, I always get "Server does not exist or access denied" error upon executing the script (please see below). I hope you can help me with this. Thank you.


I have already try setting the Persistent Security to TRUE, Setting the Data Source through instance name but still encountered the error. 


function MSSQLConnectTest()
var TestObj = ADO.CreateADOQuery();

TestObj.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;User ID=xxx;Password=xxx;Initial Catalog=xxx;Data Source=xxx";






Occasional Contributor

Re: Database connection to MS SQL Server 2008 R2

Does the server name you supply resolve to an IP address on the workstation you're running on?    Can you setup an ODBC datasource just test that those credentials and details work from that PC?

Community Hero

Re: Database connection to MS SQL Server 2008 R2

Integrated Security SSPI means that you're using whatever credentials you are logging into Windows as the same credentials for logging into the SQL server.  So, while everything else may be fine, if you're Windows user does not have SQL access to that server, you'll fail the connection.  Try removing that part of the connection string so that you are using the indicated username and password and see if that helps.

Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
Community Manager

Re: Database connection to MS SQL Server 2008 R2

Hi @eqrojas,


Were you able to resolve your question? Please share your solution with us.

Tanya Yatskovskaya
SmartBear Community and Education Manager

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
New Here?
Join us and watch the welcome video: