用户 [Microsoft][ODBC 驱动程序管理器] 未找到数据源\u001f1名称且未指定默认驱动程序"] IIS Node.js API

问题描述 投票:0回答:1

我在 IIS 中测试使用 Node.js 创建的 MSSQL 连接后端项目时遇到此错误。 我的示例 MSSQL 连接配置文件:

const config = {
   server: "server name or IP address",
   port: SQL Port,
   user: "SQL Username",
   password: "sql password.",
   database: "sql database",
   options: {
     enableArithAbort: true,
   },
};

这是我收到错误的端点处的代码:

const express = require("express");
const mssql = require("mssql/msnodesqlv8");
const config = require("./config");

const app = express();
//Customers //

app.get("/getstok", function (req, res) {
   mssql.connect(config, (error) => {
     if (error) {
       res.status(500).json({ error: "There was a problem with the MSSQL Connection", message: error.message });
     } else {
       const request = new mssql.Request();
       const query = `
       SELECT
       STOCKCARD ID
FROM IPLIKKARISIM
       `;
       request.query(query, (error, results) => {
         if (error) {
           console.error("Query error", error);
           res.status(500).json("SQL Query is not working properly.");
         } else {
           res.json(results.recordset);
         }
       });
     }
   });
});

app.listen(process.env.PORT);

通常,当我在另一台服务器上尝试时,它可以正常工作。我认为系统有缺陷等等,与代码无关,但我无法解决这个问题。

javascript node.js iis odbc iisnode
1个回答
0
投票

下载 SQL Server Native Client RDA 11.0 解决了我的问题。 这是我下载的地方:https://www.microsoft.com/en-us/download/details.aspx?id=50402

我的 odbc 数据源管理器屏幕上有这些,现在连接到 node.js 和 mssql 的后端端点正在使用 iisnode 库。

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.