1

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

3
  • You want use ODBC name or connected directly? For connect throw ODBC your connection-string contain only ODBC-alias. If you connected directly look at your version of SQL-client and write Driver= correctly. Commented Jun 7, 2016 at 11:50
  • Hi, I have written the driver name from the SQL client only. I did not understand how I can find the driver name otherwise, if not using ODBC Commented Jun 7, 2016 at 12:08
  • Is this connection-sting using by dot net odbc? if yes try Driver={SQL Server} For example: Driver={SQL Server};Server=10.0.0.1;Database=myDB;Uid=db_login;Pwd=db_passw (may be login and password must be using) Commented Jun 7, 2016 at 15:06

1 Answer 1

1

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="

Sign up to request clarification or add additional context in comments.

5 Comments

Hi, I do not have the Uid and Pwd. If I simply omit them, I get the login failed for user "" error
Without using ODBC can I connect to my server through Windows authentication?
I do not now. Create user and restrict access. It's be quickest sollution.
Hi, we have to use UserID and Pwd only for Sql authentication right? But I am using WIndows authentication.
Hi, This worked for me finally //var config = "Server={10.2.9.208};Database=trialdb;Uid=;Pwd="; on my local server

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.