I'm trying to connect from nodeJS to Sql Server on my local machine. When I run the app the following error is raised:
Login failed for user \'admin\'.', code: 'ELOGIN' },
Here's my connection details:
const sql = require('mssql');
const config = {
host:'localhost',
user:'admin',
password:'password',
database:'database',
server:'localhost\\SQLEXPRESS'
}
const poolPromise = new sql.ConnectionPool(config)
.connect()
.then(pool => {
console.log('Connected to localhost '+ config.database +' database');
return pool;
})
.catch(err => console.log('Database connection failed. Error: ', err));
module.exports = {
sql, poolPromise
}
This PoolPromise is then used in some Repository files to manage the data from database like this:
const { poolPromise } = require('./pool');
module.exports = {
create: async function (name) {
const pool = await poolPromise;
return await pool.request()
.input('nameParameter', name)
.query('INSERT INTO dbo.table(nombre) VALUES (@nameParameter)')
.then(result => {
console.log(result);
}).catch(function(err) {
console.log(err.message);
});
},
I've tried installing the msnodesqlv8 module, but it's not working. My npm version is npm: '6.4.1'.
I'm losing my mind trying to solve this. Any ideas?