Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error connecting to db #62

Closed
aerze opened this issue Aug 5, 2014 · 3 comments
Closed

Error connecting to db #62

aerze opened this issue Aug 5, 2014 · 3 comments

Comments

@aerze
Copy link

aerze commented Aug 5, 2014

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)
@patriksimek
Copy link
Collaborator

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.

@aerze
Copy link
Author

aerze commented Aug 7, 2014

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

@aerze
Copy link
Author

aerze commented Aug 8, 2014

I got it
I didn't realize our team was using MSSQL 2000 until after I read this ticket
#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.)

@aerze aerze closed this as completed Aug 8, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants