Forum Discussion

dwakchaure's avatar
2 months ago

Connecting to a SQL Server database using Integrated Security from JavaScript

I have a BDD test. One of the step definitions connects to SQL Server database and fetches some data. I use JavaScript.

This the JavaScript code I have. The connection used Integrated Security, so no need to give user id and password

var connection=ADO.CreateADOConnection();
connection.ConnectionString="Provider=SQLOLEDB;Data Source=<datasource>;Initial Catalog=<database>;Integrated Security=SSPI";
   connection.Open();

connection.Open() is throwing up a message box asking for user id and password. See the attached screenshot.

The above connection string works fine with Database Tables (Stores=>DbTable). See the attached screenshot. 

Does anyone has code sample to connect to SQL database using integration security.

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    Providing you are using the correct ODBC driver, here's the connection that I use for SQL Server

    "Provider=MSOLEDBSQL19.1; Integrated Security=SSPI; Persist Security Info=False; Initial Catalog=Your_Database_Name; Data Source=Your_Database_Server_Name; Use Encryption for Data=False;"