Problems with node-sqlserver in node.js

I am having problems connecting to a database on a computer on my network using Microsoft node -sqlserver in node.js. I am using SQL Server 2008 on a Windows 2008 server. I am remotely running my node.js on another machine in the same domain. I think the problem is with the connection string.

var sql = require('node-sqlserver'); var conn_str = 'Driver={SQL Server Native Client 10.0};Server=(win08-srv);Database=DB;Trusted_Connection={Yes}'; 

In addition, there must be a username and password for entering the database, however this was not in the example connection string from the node module.

 //open the DB connection sql.open(conn_str, function (err, conn) { if (err) { console.log("Error opening the connection!"); return; } else { console.log('Connection successful!'); return; } }); 

Printing always starts Error opening the connection! at startup.

+6
source share
3 answers

The way I was able to connect was to change my connection string. I had to change it to say Trusted_Connection{No} , and then provide login credentials.

0
source

I had the same problem. The first thing you need to do to diagnose the problem is to change the example code below:

 sql.open(conn_str, function (err, conn) { if (err) { console.log("Error opening the connection! Error was: " + err); return; } 

As soon as I did this, I got a little more error information. My mistake:

 "Error opening the connection! Error: IM002: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified" 

This basically means that you specified the wrong driver in the connection string. I solved the problem by changing the driver version from 11.0 to 10.0. You can see which drivers are installed locally (if you are in windows that I believe you are), go to:

Control Panel> Administrative Tools> Data Sources (ODBC)> Drivers (tab).

Look at your own SQL Server client and see the version number. If you do not have this driver installed, you need to download it.

+4
source

Try this connection string so that you can specify a username and password combination that is explicitly tailored to your settings.

var conn_str = "Driver = {Native SQL Server 10.0 client}; Server = TEXAS; Database = NodeMassive; Uid = WebDev; Pwd = developer1;";

0
source

Source: https://habr.com/ru/post/920889/


All Articles