简体   繁体   English

Node.js SQL Server驱动程序问题-如何解决

[英]Node.js SQL Server driver issue - How to troubleshoot

What is the correct way to troubleshoot this error with Node.js on Windows with the SQL Server driver. 使用SQL Server驱动程序在Windows上使用Node.js解决此错误的正确方法是什么。

events.js:2549: Uncaught Error: 42000: [Microsoft][SQL Server Native Client 11.0 ]Syntax error, permission violation, or other nonspecific error events.js:2549:未捕获的错误:42000:[Microsoft] [SQL Server Native Client 11.0]语法错误,权限冲突或其他非特定错误

  • It is not the SQL statement - it works in other tools - like .NET 它不是SQL语句,它可以在其他工具(如.NET)中使用
  • Doesn't seem to be the SQL connection info - it works in other tools - like .NET 似乎不是SQL连接信息-它可以在其他工具(如.NET)中使用

Any thoughts? 有什么想法吗? What is the correct way for completely uninstalling node.js and starting over. 完全卸载node.js并重新开始的正确方法是什么? I don't think my last install removed all my global modules. 我不认为我上一次安装删除了所有全局模块。

var sql = require('node-sqlserver');
var _ = require('underscore')._;

var connstr = "Driver={SQL Server Native Client 11.0};Server=localhost;" +
            "Initial Catalog=CDDB;Trusted_Connection={Yes}";

sql.open(connstr, function (err, conn) {
    if (err) {
        console.log("Error opening the connection");
        return;
    } else {
        var stmt = "select top 10 * from Client";
        conn.query(connstr, stmt, function (err, results) {
            if (err) {
                console.log("Error running query!");
                return;
            }
            _.each(results, function (row) {
                console.log(row[0]);
            });
        });
    }
}); 

First idea : Are users which runs your node.exe process and the one defined on your application pool - or maybe your current user account if you are using VS.NET to check your code are the same ? 第一个想法:运行node.exe进程的用户和在应用程序池中定义的进程的用户-如果您使用VS.NET来检查代码,或者当前的用户帐户是否相同?

To troubleshoot : I would use node-inspector - it allows to set up breakpoints onto your node.js code 要解决的问题:我将使用node-inspector-它允许在您的node.js代码上设置断点

To install it : npm install -g node-inspector 要安装它:npm install -g node-inspector

To run it : node --debug your-nodeapp-file.js 运行它:node --debug your-nodeapp-file.js

Launch another command line and run the following program : node-inspector 启动另一个命令行并运行以下程序:node-inspector

Sorry but i do not have SQL Server to try your code, hope this help anyway. 抱歉,但是我没有SQL Server来尝试您的代码,无论如何希望对您有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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