Suchitra Iyer
Suchitra Iyer

Reputation: 53

SQL Server connection with jQuery and node js

I am using node js to connect to a SQL Server that has only Windows authentication. The database is stored on a centralised machine.

The database returns some json data which I place at some address (http://10.2.9.208:8081/me). This is the address of my PC i.e, (https://localhost/me) and I retrieve it using a jQuery call.

This jQuery call is made from a html page to retrieve jsonp formatted data to avoid cross origin problems.

This is my jQuery call in a page index12.html

$.get("http://10.2.9.208:8081/me?callback=?", function (data) {

        dataset_module_errors = data;
    });

The connection strings are in a page app.js

My connection string which I used to connect with database was

var config = {
server: '10.2.12.153',                          
database: 'DFMProAnalyticsCopy',       // my table is within this server
port: 1433                             // default port number
};

This throws an error 'LOGIN ERROR' as it considered user & password as '' -> null strings.

So I eventually used this for windows authentication

var config = 
"Driver={SQL Server Native Client 11.0};
Server=10.2.12.153,1433;
Database=DFMProAnalyticsCopy;
Trusted_Connection={Yes}";

Now this throws two errors ->

  1. ConnectionError: Unknown driver SQL Server Native Client 11.0!
  2. GET http://10.2.9.208:8081/me?callback=? 500 (Internal Server Error)

I have referred to How to find the ODBC driver name for a connection string? to find the driver name and have verified it twice.

All of this has been working perfectly fine when I accessed my local database installed on my PC through the JQuery call. I had user SQL Authentication on my PC.Windows authentication gives the error

login failed for user '' 

when accessed through node js.

I have done some mistake in accessing the central DB.

Please guide me through it.

EDIT 1: Since this is Windows authentication, I do not have a username or password

Upvotes: 1

Views: 1631

Answers (1)

nick_n_a
nick_n_a

Reputation: 206

Form Connection-string for OdbcConnection is

Driver={SQL Server};Server=10.0.0.1;Database=db_alias;Uid=db_login;Pwd=db_passw

Do not change driver parametr. And thanks Suchitra Iyer, for local server connection-string is

"Server={10.2.9.208};Database=trialdb;Uid=;Pwd="

Upvotes: 1

Related Questions