Forum Discussion

eqrojas's avatar
eqrojas
New Contributor
6 years ago

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

  • Poida's avatar
    Poida
    Occasional Contributor

    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?

    • tristaanogre's avatar
      tristaanogre
      Esteemed Contributor

      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.