msnodesql fails inside iisnode; works on command-line #88

schmod opened this Issue Nov 6, 2012 · 6 comments


None yet
3 participants

schmod commented Nov 6, 2012

I have a very small script that connects to, and runs a simple query on a SQL Server 2005 Database using the msnodesql.

I can run this script just fine from the command line, and everything works exactly as one would expect it to.

However, if I kick this script off from within iisnode, I get the following:

iisnode encountered an error when processing the request.

HTTP status: 500
HTTP reason: Internal Server Error

and no further details (node writes nothing to stdout or stderr).

What the heck is going on, and how can I troubleshoot this further? I've got the latest version of the module (0.2.0), node 0.8.14, iisnode 0.2.0, and SQL Server Native Client 11.0; all running on Win7 (x64).

jkint was assigned Nov 6, 2012


jkint commented Nov 6, 2012

Can you post a version of the script that exhibits the problem? Also, what version of SQL Server are you running?


schmod commented Nov 7, 2012

Here's a script that reproduces the problem:

var sql = require('msnodesql');

var driver = 'SQL Server Native Client 11.0';
var server = 'myServer\\myInstance';
var user = 'sa';
var pwd = 'myPassword';
var database = 'myDatabase';
var useTrustedConnection = true;
var conn_str = "Driver={" + driver + "};Server=" + server + ";" + (useTrustedConnection === true ? "Trusted_Connection={Yes};" : "UID=" + user + ";PWD=" + pwd + ";") + "Database={" + database + "};";, function(err,conn){
    conn.queryRaw("SELECT @@version",function(err,results){

From the command line:
C:\myProject>node test.js

{ meta: [ { name: '', size: 300, nullable: true, type: 'text' } ],
  rows: [ [ 'Microsoft SQL Server 2005 - 9.00.5057.00 (Intel X86) \n\tMar 25 2011 13:50:04 \n\tCopyright (c) 1988-2005 Microsoft Corporation\n\tStandard Edition on Windows NT 6.0 (Build 6002: Service Pack 2)\n' ] ] }

From iisnode (http://localhost/test.js):

HTTP status: 500
HTTP reason: Internal Server Error

My web.config for this directory:

<?xml version="1.0" encoding="UTF-8"?>
            <add name="iisnode" path="test.js" verb="*" modules="iisnode" resourceType="Unspecified" preCondition="bitness64" />
        <iisnode watchedFiles="*.js"></iisnode>

jkint commented Nov 7, 2012

Could this be related to the permissions of the web server being different than your user credentials?

I wonder if it would work if you were to try this with SQL Server authentication using the same account.

schmod commented Nov 7, 2012

Bingo. I somehow missed that the Windows Authentication (rightly) didn't pick up my IIS user.

Maybe the module should throw an error when authentication fails?


jkint commented Nov 8, 2012

It should have. What were the contents of the error variable in the callback to


jguerin commented Nov 21, 2012

Closing due to inactivity

jguerin closed this Nov 21, 2012

jkint was unassigned by schmod Apr 1, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment