Dong Lam Trien

Dong Lam Trien

  • 830
  • 986
  • 147.2k

Connection fail to SQL Server using NodeJS mssql msnodesqlv8 from the

Mar 26 2024 4:50 AM

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

var sql = require('mssql/msnodesqlv8');

const config = {
    user: 'sa',
    password: 'Coffee',
    server: 'localhost',
    database: 'Cafe',
    driver: 'msnodesqlv8',
    port: 1433,
    options: {
      trustedConnection: true,
      enableArithAbort: true
    }    
  };

const conn = new sql.ConnectionPool(config).connect().then(pool => {
    return pool;
  });

When I connect to the internal server, I get an error:
ConnectionError: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
    at PrivateConnection.callback2 (D:\NodeJS\node_modules\mssql\lib\msnodesqlv8\connection-pool.js:46:17)
    at Immediate.<anonymous> (D:\NodeJS\node_modules\msnodesqlv8\lib\connection.js:41:14)
    at process.processImmediate (node:internal/timers:478:21) {
  code: undefined,
  originalError: [Error: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified] {
    sqlstate: 'IM002',
    code: 0,
    severity: 0,
    serverName: '',
    procName: '',
    lineNumber: 0
  }
}
 


Answers (4)