4

I want to use NodeJS to connect to a SQL Server 2008 R2 Express database. I've looked around at what NPM has to offer. Have tried mssql, mssql-simple and node-SQLServer.

Some of them can be installed some do not. And those who do, will not access SQL Server.

Error when using mssql:

[Error: connection to .\SQLEXPRESS:1433 - failed Error: getaddrinfo ENOENT]
var sql = require('mssql');
var config = {
user: 'root',
password: 'xxx',
server: '.\SQLEXPRESS',
database: 'test'
} var connection = new sql.Connection(config, function(err) {
console.log(err);
});

If there is anyone who has got something to work between NodeJS and SQL Server Express? Which module and version do you use?

3 Answers 3

1

Problem was that i did not have TCP/IP Enabled. How to check and Enable MSSQL TCP/IP MSDN Next you do not have to use "server: '.\SQLEXPRESS'" after enabled TCP/IP 127.0.0.1 works fine!

1
  • 1
    Hi Krister, which module did you end up using?
    – Katya S
    Apr 25, 2014 at 12:37
0

you could also just put 'localhost' as your server.

0

// const sql = require("msnodesqlv8");

USE THIS

npm i msnodesqlv8

it is easy to use

1
  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Dec 5, 2022 at 10:03

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.