Node JS and SQL Server 2008 R2 Express
-
21-12-2019 - |
Question
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?
La solution
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!
Autres conseils
you could also just put 'localhost' as your server.