找不到数据源名称,并且未指定默认驱动程序 nodejs



我正在将我的代码从本地部署到Web服务器(Windows 2012(。

我收到以下错误。

错误

{ 连接错误: [Microsoft][ODBC 驱动程序管理器] 找不到数据源名称,并且在 msnodesql.open (c:\apps\vimode_modules\mssql\lib\msnodesqlv8.js:174:17(

我的代码:

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();
});
}

我已经设置了一个DSN连接,它在Web服务器中工作正常。

驱动程序名称不正确。它需要与DSN中显示的名称匹配。