简体   繁体   中英

Data source name not found and no default driver specified nodejs

I was deploying my code from local to web server(Windows 2012).

I am getting the following error.

Error { ConnectionError: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified at msnodesql.open (c:\\apps\\vim\\node_modules\\mssql\\lib\\msnodesqlv8.js:174:17)

My Code:

function ConnectToSql() {

  var sql = require('mssql/msnodesqlv8');
  var config = {
    driver: 'msnodesqlv8',
    connectionString: 'Driver={SQL Server Native Client 11.0};Server=xxxxx;Database=xxxx;Trusted_Connection=yes;',
  };
  const pool = new sql.ConnectionPool(config).connect().then(pool => {
      return pool.request().query("select 1 as number")
      }).then(result => {
        sql.close();
      }).catch(err => {
        sql.close();
      });

}

I have setup a DSN connection and it is working fine from within in the WebServer.

The Driver name was incorrect. It needs to match the name that shows inside DSN.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM