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.
source share