cancel
Showing results for 
Search instead for 
Did you mean: 

Database connection to MS SQL Server 2008 R2

Highlighted
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";

 

try
{

TestObj.Open();

Log.Message("Success!!");
}
catch(e)
{
Log.Message(e.message);
}

}

3 REPLIES 3
Highlighted
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?

Highlighted
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
[Community Expert Group]
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
Highlighted
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 Gorbunova
SmartBear Community Manager

 Join SmartBear Connect next April in Boston to meet with software development, API and testing experts from around the world! Get your ticket today!