Yoav Keren
Yoav Keren

Reputation: 99

Connection fail to SQL Server using NodeJS mssql msnodesqlv8 from the server

I wrote a little service in NodeJS which connects to SQL Server.

In my local machine, the connection is established successfully. After putting my files in a remote machine, I get this error:

ConnectionError: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

I use windows authentication but when the username didn't have permissions, I got a different error.

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

const mypool = new mssql.ConnectionPool({
        driver: 'msnodesqlv8',
        server: myhost,
        database: mydb,
        port: 1443,
        options: {
            trustedConnection: true,
            enableArithAbort: true
        }
});

mypool.connect().then(pool => {
    console.log('Connected to MSSQL (DB: mydb)');
    return pool;
}).catch(err => console.log('Database Connection Failed! Bad Config: ', err))

Upvotes: 1

Views: 1601

Answers (1)

Blossom
Blossom

Reputation: 123

Try modifying the connection pool as below,

const pool=new sql.ConnectionPool (config, function(err){
 if(err){
   console.log('Error while creating connection pool \n'+err);
 }
});

Upvotes: 0

Related Questions