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

RangeError: Offset is out of bounds #442

Closed
grzegorzkozlowski opened this issue Sep 6, 2016 · 2 comments
Closed

RangeError: Offset is out of bounds #442

grzegorzkozlowski opened this issue Sep 6, 2016 · 2 comments

Comments

@grzegorzkozlowski
Copy link

Hi Everyone. This is my first post on Github, so please excuse me for any mistakes.
I'm trying to connect to my azure MS SQL database using node.js.
Since 2 days I'm fighting with a problem for which I cannot find any answers on the internet.
I'm experienced .NET/MS SQL developer, but really a newbie in Node.JS :) But I'm progressing.

My code is:

var Connection = require('tedious').Connection;
var config = {
userName: '[username]',
password: '[password]',
server: '[server].database.windows.net',
databes: '[database]'
};
config.options = {encrypt: true, database: '[database]'}
config.options.debug = {
packet: true,
data: true,
payload: true,
token: true,
log: true
}
var connection = new Connection(config);
connection.on('debug', function(text) {
console.log(text);
});
var Request = require('tedious').Request;
var TYPES = require('tedious').TYPES;
function executeStatement() {
request = new Request("SELECT * FROM table;", function(err) {
if (err) {
console.log(err);}
});
var result = "";
request.on('row', function(columns) {
columns.forEach(function(column) {
if (column.value === null) {
console.log('NULL');
} else {
result+= column.value + " ";
}
});
console.log(result);
result ="";
});
request.on('done', function(rowCount, more) {
console.log(rowCount + ' rows returned');
});
connection.execSql(request);
}

Error I get:

buffer.js:778
return this.ucs2Write(string, offset, length);
^

RangeError: Offset is out of bounds
at RangeError (native)
at Buffer.write (buffer.js:778:21)
at WritableTrackingBuffer.writeString (/opt/bitnami/nodejs/lib/node_modules/tedious/lib/tracking-buffer/writable-tracking-buffer.js:216:38)
at Login7Payload.addVariableDataString (/opt/bitnami/nodejs/lib/node_modules/tedious/lib/login7-payload.js:228:25)
at Login7Payload.createVariableData (/opt/bitnami/nodejs/lib/node_modules/tedious/lib/login7-payload.js:194:12)
at new Login7Payload (/opt/bitnami/nodejs/lib/node_modules/tedious/lib/login7-payload.js:111:25)
at Connection.sendLogin7Packet (/opt/bitnami/nodejs/lib/node_modules/tedious/lib/connection.js:602:21)
at Connection.message (/opt/bitnami/nodejs/lib/node_modules/tedious/lib/connection.js:1054:16)
at Connection.dispatchEvent (/opt/bitnami/nodejs/lib/node_modules/tedious/lib/connection.js:519:45)
at MessageIO. (/opt/bitnami/nodejs/lib/node_modules/tedious/lib/connection.js:439:23)

Can you please help me?
My Node version is 6.4.0 and I'm using Bitnami account.

@spanditcaa
Copy link
Member

spanditcaa commented Sep 6, 2016

@grzegorzkozlowski there was a bug with node 6.4.0 -- try 6.5 or go back to 6.3.x

see #431 for details.

@arthurschreiber
Copy link
Collaborator

Closing this as this was a bug in Node.js 6.4.0 and not in tedious.

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

3 participants