Node-mssql: Error connecting to db

Created on 5 Aug 2014  路  3Comments  路  Source: tediousjs/node-mssql

I'm pretty new to using MS SQL, sorry if this is obvious to others.
I'm trying to connect using this config object

var config = {
    user: 'gsuarez', // Is this db users or windows users?
    password: '######',
    server: '10.10.3.240', // is this supposed to use ip or hostname?
    database: 'PhoneNet',
    domain: 'phone.local',
    debug: true,
    options: {}
}

most importantly I get this, and I'm lost as to what it is even after tracing it back.

root@ServerRoomB-Ubuntu:/node/genexpress# node app.js
Express server listening on port 3000

events.js:72
        throw er; // Unhandled 'error' event
              ^
TypeError: Uncaught, unspecified "error" event.
    at TypeError (<anonymous>)
    at Connection.EventEmitter.emit (events.js:74:15)
    at Parser.<anonymous> (/node/genexpress/node_modules/mssql/node_modules/tedious/lib/connection.js:566:15)
    at Parser.EventEmitter.emit (events.js:95:17)
    at Parser.nextToken (/node/genexpress/node_modules/mssql/node_modules/tedious/lib/token/token-stream-parser.js:102:14)
    at Parser.addBuffer (/node/genexpress/node_modules/mssql/node_modules/tedious/lib/token/token-stream-parser.js:68:17)
    at Connection.sendDataToTokenStreamParser (/node/genexpress/node_modules/mssql/node_modules/tedious/lib/connection.js:791:35)
    at Connection.STATE.SENT_NTLM_RESPONSE.events.data (/node/genexpress/node_modules/mssql/node_modules/tedious/lib/connection.js:199:23)
    at Connection.dispatchEvent (/node/genexpress/node_modules/mssql/node_modules/tedious/lib/connection.js:667:59)
    at MessageIO.<anonymous> (/node/genexpress/node_modules/mssql/node_modules/tedious/lib/connection.js:599:22)

Most helpful comment

I got it
I didn't realize our team was using MSSQL 2000 until after I read this ticket
https://github.com/patriksimek/node-mssql/issues/36 and checked because we had the exact same issues.
Using this it works right away.

    options: {
        tdsVersion: '7_1'
    }

Thanks for you help! (and for your connector.)

All 3 comments

Please, update your mssql to latest version 1.1.1 and attach an error listener to the 'connection' object.

connection.on("error", function(err) { console.error(err.stack); });

This should print original error to the console. Could you please post the error here so I can figure out where the problem is? Thanks.

Thanks for your help on this.

var connection = new sql.Connection(config, function(err) {
    // Check for errors
    if (err) throw err;

    // Query
    var request = new sql.Request(connection) ;
    request.query('select 1 as number', function (err, recordset) {
        // Add error checks
        if (err) throw err;
        console.dir(recordset);
    })
})
connection.on("error", function(err) { 
    console.log('Error');
    console.error(err.stack); 
    console.log(err);
});

This^ caused this v

root@ServerRoomB-Ubuntu:/node/genexpress# node app.js
Express server listening on port 3000
Error
undefined
Unrecognized token 0 at offset 204

I got it
I didn't realize our team was using MSSQL 2000 until after I read this ticket
https://github.com/patriksimek/node-mssql/issues/36 and checked because we had the exact same issues.
Using this it works right away.

    options: {
        tdsVersion: '7_1'
    }

Thanks for you help! (and for your connector.)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

agilitehub picture agilitehub  路  4Comments

jeetendra-choudhary picture jeetendra-choudhary  路  3Comments

PhantomRay picture PhantomRay  路  4Comments

rsmolkin picture rsmolkin  路  3Comments

andrewmcgivery picture andrewmcgivery  路  5Comments