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

Russian chars does not work in queries with ucs2. #138

Closed
wants to merge 1 commit into from

Conversation

drudrum
Copy link

@drudrum drudrum commented Mar 27, 2014

When i remove 'ucs2', queries goes properly. I am connecting to TDS7.2 MSSQL(windows machine)

When i remove 'ucs2', queries goes properly. I am connecting to TDS7.2 MSSQL(windows machine)
@patriksimek
Copy link
Collaborator

Could you please post some code snippet? I have no problem with russian characters at all.

@drudrum
Copy link
Author

drudrum commented Apr 1, 2014

base collation = SQL_Latin1_General_CP1251_CI_AS

var findStr="ТЮМ";
var sql="SELECT TOP 15 * FROM OMS_COUNTRY WHERE UPPER(NAME) LIKE '"+findStr+"%'";

Request return 0 rows result

@patriksimek
Copy link
Collaborator

Could you please post a Tedious code? At least I need to see how you specify parameters in your requests.

@drudrum
Copy link
Author

drudrum commented Apr 2, 2014

var crypto = require('crypto');
var thunky = require('thunky');
var Connection = require('tedious').Connection;
var Request = require('tedious').Request;
var sameTime = require('../small-node-libs/sameTime.js');
var iconv = require('iconv-lite');

//....

var processRow=function(r,columns){
  columns.forEach(function(column) {
    if (typeof(column.value)=='string')
      r[column.metadata.colName]=iconv.decode(new Buffer(column.value, 'binary'),'win1251');//win1251toUtf8.convert().toString();
    else
      r[column.metadata.colName]=column.value;
  });
  return r;
}

//....
var sConfig={
  server: '192.168.0.232',
  //port: 1433,
  userName: 'xxxx',
  password: 'xxxxxxxx'
};
//....
var queryLikeAMongoDb=function(qSql,mcb){
  var connection;
  connectionsLimit.run(function(){
    connection = new Connection(cConfig);

    connection.on('connect', function(connectionErr) {
      if (connectionErr) {
        console.log("db connect error",connectionErr);
        return mcb(connectionErr);
      }

      var request = new Request(qSql, function(queryErr, rowCount) {
        //Request ended
        connection.close();
        connectionsLimit.e();

        mcb(queryErr,null);
      });//create request

      request.on('row', function(columns) {
        var r=processRow({},columns);

        mcb(null,r);
      });

      connection.execSql(request);

      return null;
    });//open connection to db
  });//run connect under limit
};//queryLikeAMongoDb


var findStr="РОССИЯ";
var sql="SELECT TOP 15 * FROM OMS_COUNTRY WHERE UPPER(NAME) LIKE '"+findStr+"%'";
queryLikeAMongoDb(sql,function(err,row){
  //This callback calls one time, without error.

  //When i remove "ucs2" from buffer.writeString(parameter.value.toString(), 'ucs2')
  //callback called 2 times. first with row-Russia, second without row and error.
});

@patriksimek
Copy link
Collaborator

Sill I can't reproduce the issue. Could you please run this code in your environment and post results here? It should print a lot of debug messages to the console. Thank you.

var Connection = require('tedious').Connection;
var Request = require('tedious').Request;

var config = {
  server: '192.168.0.232',
  userName: '...',
  password: '...',
  options: {
    debug: {
      packet: true,
      data: true,
      payload: true,
      token: true,
      log: true
    }
  }
};

var connection = new Connection(config);

connection.on('connect', function(err) {
    request = new Request("SELECT TOP 15 * FROM OMS_COUNTRY WHERE UPPER(NAME) LIKE 'РОССИЯ%'", function(err, rowCount) {
    if (err) {
      console.error(err);
    } else {
      console.log('done');
    }

    connection.close();
  });

  connection.execSql(request);
});

connection.on('debug', function(text) {
    console.log(text);
});
``

@patriksimek patriksimek self-assigned this Apr 2, 2014
@drudrum
Copy link
Author

drudrum commented Apr 3, 2014

Mmmm, i can't understand, but now query goes right with one row... In my code also goes properly.
but nothing has changed since opened as an issue.

I returned back 'ucs2', then run your code, then run my code, and i can't understand why..

connected to 192.168.0.232:1433

Sent
  type:0x12(PRELOGIN), status:0x01(EOM), length:0x002F, spid:0x0000, packetId:0x01, window:0x00
  0000  00001A00 06010020 00010200 21000103 00220004 04002600 01FF0000 00010001  ....... ....!... ."....&. ........
  0020  02000000 000000  .......
  PreLogin - version:0.0.0.1 1, encryption:0x02(NOT_SUP), instopt:0x00, threadId:0x00000000, mars:0x00(OFF)
State change: Connecting -> SentPrelogin

Received
  type:0x04(TABULAR_RESULT), status:0x01(EOM), length:0x002B, spid:0x0000, packetId:0x01, window:0x00
  0000  00001A00 06010020 00010200 21000103 00220000 04002200 01FF0900 05770000  ....... ....!... ."....". .....w..
  0020  020000  ...
  PreLogin - version:9.0.5.119 0, encryption:0x02(NOT_SUP), instopt:0x00, threadId:0x00000000, mars:0x00(OFF)

Sent
  type:0x10(LOGIN7), status:0x01(EOM), length:0x00B0, spid:0x0000, packetId:0x01, window:0x00
  0000  A8000000 02000972 00100000 00000000 445A0000 00000000 A0000008 98FEFFFF  .......r........ DZ...... ........
  0020  09040000 5E000A00 72000200 76000B00 8C000700 9A000000 9A000000 9A000700  ....^... r...v... ........ ........
  0040  A8000000 A8000000 01020304 0506A800 0000A800 0000A800 00000000 00007800  ........ ........ ........ ......x.
  0060  75006200 75006E00 74007500 32003100 36007300 610091A5 03A523A5 03A582A5  u.b.u.n. t.u.2.1. 6.s.a... ..#.....
  0080  43A592A5 93A502A5 22A5B6A5 54006500 64006900 6F007500 73005400 65006400  C....... "...T.e. d.i.o.u. s.T.e.d.
  00A0  69006F00 75007300   i.o.u.s. 
  Login7 - TDS:0x72090002, PacketSize:0x00001000, ClientProgVer:0x00000000, ClientPID:0x00005A44, ConnectionID:0x00000000
           Flags1:0xA0, Flags2:0x00, TypeFlags:0x00, Flags3:0x08, ClientTimezone:-360, ClientLCID:0x00000409
           Hostname:'xubuntu216', Username:'sa', Password:'***', AppName:'Tedious', ServerName:'undefined', LibraryName:'Tedious'
           Language:'undefined', Database:'undefined', SSPI:'', AttachDbFile:'', ChangePassword:''
State change: SentPrelogin -> SentLogin7WithStandardLogin

Received
  type:0x04(TABULAR_RESULT), status:0x01(EOM), length:0x01A5, spid:0x004A, packetId:0x01, window:0x00
  0000  E3290001 0D4D0065 00640069 0061006C 006F0067 005F0077 006F0072 006B0006  .)...M.e.d.i.a.l.o.g._.w.o.r.k..
  0020  6D006100 73007400 65007200 AB7A0045 16000002 002C0043 00680061 006E0067  m.a.s.t. e.r..z.E.....,.C.h.a.n.g
  0040  00650064 00200064 00610074 00610062 00610073 00650020 0063006F 006E0074  .e.d. .d.a.t.a.b.a.s.e. .c.o.n.t
  0060  00650078 00740020 0074006F 00200027 004D0065 00640069 0061006C 006F0067  .e.x.t. .t.o. .'.M.e.d.i.a.l.o.g
  0080  005F0077 006F0072 006B0027 002E000A 4D004C00 30003100 54004F00 4F004400  ._.w.o.r.k.'.... M.L.0.1. T.O.O.D.
  00A0  30003200 00010000 00E30800 07050904 D0006A00 E3170002 0A750073 005F0065  0.2..... ........ ..j..... .u.s._.e
  00C0  006E0067 006C0069 00730068 0000AB70 00471600 00010027 00430068 0061006E  .n.g.l.i.s.h...p.G.....'.C.h.a.n
  00E0  00670065 00640020 006C0061 006E0067 00750061 00670065 00200073 00650074  .g.e.d. .l.a.n.g.u.a.g.e. .s.e.t
  0100  00740069 006E0067 00200074 006F0020 00750073 005F0065 006E0067 006C0069  .t.i.n.g. .t.o. .u.s._.e.n.g.l.i
  0120  00730068 002E000A 4D004C00 30003100 54004F00 4F004400 30003200 00010000  .s.h.... M.L.0.1. T.O.O.D. 0.2.....
  0140  00AD3600 01720900 02164D00 69006300 72006F00 73006F00 66007400 20005300  ..6..r.. ..M.i.c. r.o.s.o. f.t. .S.
  0160  51004C00 20005300 65007200 76006500 72000000 00000900 0577E313 00040434  Q.L. .S. e.r.v.e. r....... .w.....4
  0180  00300039 00360004 34003000 39003600 FD000000 00000000 00000000 00  .0.9.6.. 4.0.9.6. ........ .....
{ name: �[32m'ENVCHANGE'�[39m,
  type: �[32m'DATABASE'�[39m,
  event: �[32m'databaseChange'�[39m,
  oldValue: �[32m'master'�[39m,
  newValue: �[32m'Medialog_work'�[39m }
{ number: �[33m5701�[39m,
  state: �[33m2�[39m,
  class: �[33m0�[39m,
  message: �[32m'Changed database context to \'Medialog_work\'.'�[39m,
  serverName: �[32m'ML01TOOD02'�[39m,
  procName: �[32m''�[39m,
  lineNumber: �[33m1�[39m,
  name: �[32m'INFO'�[39m,
  event: �[32m'infoMessage'�[39m }
{ name: �[32m'ENVCHANGE'�[39m,
  type: �[32m'SQL_COLLATION'�[39m,
  event: �[32m'sqlCollationChange'�[39m,
  oldValue: <Buffer >,
  newValue: <Buffer 09 04 d0 00 6a> }
{ name: �[32m'ENVCHANGE'�[39m,
  type: �[32m'LANGUAGE'�[39m,
  event: �[32m'languageChange'�[39m,
  oldValue: �[32m''�[39m,
  newValue: �[32m'us_english'�[39m }
{ number: �[33m5703�[39m,
  state: �[33m1�[39m,
  class: �[33m0�[39m,
  message: �[32m'Changed language setting to us_english.'�[39m,
  serverName: �[32m'ML01TOOD02'�[39m,
  procName: �[32m''�[39m,
  lineNumber: �[33m1�[39m,
  name: �[32m'INFO'�[39m,
  event: �[32m'infoMessage'�[39m }
{ name: �[32m'LOGINACK'�[39m,
  event: �[32m'loginack'�[39m,
  interface: �[32m'SQL_TSQL'�[39m,
  tdsVersion: �[32m'7_2'�[39m,
  progName: �[32m'Microsoft SQL Server\u0000\u0000'�[39m,
  progVersion: 
   { major: �[33m9�[39m,
     minor: �[33m0�[39m,
     buildNumHi: �[33m5�[39m,
     buildNumLow: �[33m119�[39m } }
{ name: �[32m'ENVCHANGE'�[39m,
  type: �[32m'PACKET_SIZE'�[39m,
  event: �[32m'packetSizeChange'�[39m,
  oldValue: �[33m4096�[39m,
  newValue: �[33m4096�[39m }
Packet size changed from 4096 to 4096
{ name: �[32m'DONE'�[39m,
  event: �[32m'done'�[39m,
  more: �[33mfalse�[39m,
  sqlError: �[33mfalse�[39m,
  attention: �[33mfalse�[39m,
  serverError: �[33mfalse�[39m,
  rowCount: �[90mundefined�[39m,
  curCmd: �[33m0�[39m }
State change: SentLogin7WithStandardLogin -> LoggedInSendingInitialSql

Sent
  type:0x01(SQL_BATCH), status:0x01(EOM), length:0x02DA, spid:0x0000, packetId:0x01, window:0x00
  0000  16000000 12000000 02000000 00000000 00000100 00007300 65007400 20007400  ........ ........ ......s. e.t. .t.
  0020  65007800 74007300 69007A00 65002000 32003100 34003700 34003800 33003600  e.x.t.s. i.z.e. . 2.1.4.7. 4.8.3.6.
  0040  34003700 73006500 74002000 71007500 6F007400 65006400 5F006900 64006500  4.7.s.e. t. .q.u. o.t.e.d. _.i.d.e.
  0060  6E007400 69006600 69006500 72002000 6F006E00 0A007300 65007400 20006100  n.t.i.f. i.e.r. . o.n...s. e.t. .a.
  0080  72006900 74006800 61006200 6F007200 74002000 6F006600 66000A00 73006500  r.i.t.h. a.b.o.r. t. .o.f. f...s.e.
  00A0  74002000 6E007500 6D006500 72006900 63005F00 72006F00 75006E00 64006100  t. .n.u. m.e.r.i. c._.r.o. u.n.d.a.
  00C0  62006F00 72007400 20006F00 66006600 0A007300 65007400 20006100 6E007300  b.o.r.t.  .o.f.f. ..s.e.t.  .a.n.s.
  00E0  69005F00 77006100 72006E00 69006E00 67007300 20006F00 6E000A00 73006500  i._.w.a. r.n.i.n. g.s. .o. n...s.e.
  0100  74002000 61006E00 73006900 5F007000 61006400 64006900 6E006700 20006F00  t. .a.n. s.i._.p. a.d.d.i. n.g. .o.
  0120  6E000A00 73006500 74002000 61006E00 73006900 5F006E00 75006C00 6C007300  n...s.e. t. .a.n. s.i._.n. u.l.l.s.
  0140  20006F00 6E000A00 73006500 74002000 63006F00 6E006300 61007400 5F006E00   .o.n... s.e.t. . c.o.n.c. a.t._.n.
  0160  75006C00 6C005F00 79006900 65006C00 64007300 5F006E00 75006C00 6C002000  u.l.l._. y.i.e.l. d.s._.n. u.l.l. .
  0180  6F006E00 0A007300 65007400 20006300 75007200 73006F00 72005F00 63006C00  o.n...s. e.t. .c. u.r.s.o. r._.c.l.
  01A0  6F007300 65005F00 6F006E00 5F006300 6F006D00 6D006900 74002000 6F006600  o.s.e._. o.n._.c. o.m.m.i. t. .o.f.
  01C0  66000A00 73006500 74002000 69006D00 70006C00 69006300 69007400 5F007400  f...s.e. t. .i.m. p.l.i.c. i.t._.t.
  01E0  72006100 6E007300 61006300 74006900 6F006E00 73002000 6F006600 66000A00  r.a.n.s. a.c.t.i. o.n.s. . o.f.f...
  0200  73006500 74002000 6C006100 6E006700 75006100 67006500 20007500 73005F00  s.e.t. . l.a.n.g. u.a.g.e.  .u.s._.
  0220  65006E00 67006C00 69007300 68000A00 73006500 74002000 64006100 74006500  e.n.g.l. i.s.h... s.e.t. . d.a.t.e.
  0240  66006F00 72006D00 61007400 20006D00 64007900 0A007300 65007400 20006400  f.o.r.m. a.t. .m. d.y...s. e.t. .d.
  0260  61007400 65006600 69007200 73007400 20003700 0A007300 65007400 20007400  a.t.e.f. i.r.s.t.  .7...s. e.t. .t.
  0280  72006100 6E007300 61006300 74006900 6F006E00 20006900 73006F00 6C006100  r.a.n.s. a.c.t.i. o.n. .i. s.o.l.a.
  02A0  74006900 6F006E00 20006C00 65007600 65006C00 20007200 65006100 64002000  t.i.o.n.  .l.e.v. e.l. .r. e.a.d. .
  02C0  63006F00 6D006D00 69007400 74006500 6400  c.o.m.m. i.t.t.e. d.

Received
  type:0x04(TABULAR_RESULT), status:0x01(EOM), length:0x0152, spid:0x004A, packetId:0x01, window:0x00
  0000  FD0100BE 00000000 00000000 00FD0100 BA000000 00000000 0000FD01 00BA0000  ........ ........ ........ ........
  0020  00000000 000000FD 0100B900 00000000 00000000 FD0100B9 00000000 00000000  ........ ........ ........ ........
  0040  00FD0100 B9000000 00000000 0000FD01 00B90000 00000000 000000FD 0100BA00  ........ ........ ........ ........
  0060  00000000 00000000 FD0100BA 00000000 00000000 00E32B00 020A7500 73005F00  ........ ........ ......+. ..u.s._.
  0080  65006E00 67006C00 69007300 68000A75 0073005F 0065006E 0067006C 00690073  e.n.g.l. i.s.h..u.s._.e.n.g.l.i.s
  00A0  006800AB 70004716 00000100 27004300 68006100 6E006700 65006400 20006C00  .h..p.G. ....'.C. h.a.n.g. e.d. .l.
  00C0  61006E00 67007500 61006700 65002000 73006500 74007400 69006E00 67002000  a.n.g.u. a.g.e. . s.e.t.t. i.n.g. .
  00E0  74006F00 20007500 73005F00 65006E00 67006C00 69007300 68002E00 0A4D004C  t.o. .u. s._.e.n. g.l.i.s. h....M.L
  0100  00300031 0054004F 004F0044 00300032 00000A00 0000FD01 00F90000 00000000  .0.1.T.O.O.D.0.2........ ........
  0120  000000FD 0100F900 00000000 00000000 FD0100F9 00000000 00000000 00FD0000  ........ ........ ........ ........
  0140  F9000000 00000000 0000  ........ ..
{ name: �[32m'DONE'�[39m,
  event: �[32m'done'�[39m,
  more: �[33mtrue�[39m,
  sqlError: �[33mfalse�[39m,
  attention: �[33mfalse�[39m,
  serverError: �[33mfalse�[39m,
  rowCount: �[90mundefined�[39m,
  curCmd: �[33m190�[39m }
{ name: �[32m'DONE'�[39m,
  event: �[32m'done'�[39m,
  more: �[33mtrue�[39m,
  sqlError: �[33mfalse�[39m,
  attention: �[33mfalse�[39m,
  serverError: �[33mfalse�[39m,
  rowCount: �[90mundefined�[39m,
  curCmd: �[33m186�[39m }
{ name: �[32m'DONE'�[39m,
  event: �[32m'done'�[39m,
  more: �[33mtrue�[39m,
  sqlError: �[33mfalse�[39m,
  attention: �[33mfalse�[39m,
  serverError: �[33mfalse�[39m,
  rowCount: �[90mundefined�[39m,
  curCmd: �[33m186�[39m }
{ name: �[32m'DONE'�[39m,
  event: �[32m'done'�[39m,
  more: �[33mtrue�[39m,
  sqlError: �[33mfalse�[39m,
  attention: �[33mfalse�[39m,
  serverError: �[33mfalse�[39m,
  rowCount: �[90mundefined�[39m,
  curCmd: �[33m185�[39m }
{ name: �[32m'DONE'�[39m,
  event: �[32m'done'�[39m,
  more: �[33mtrue�[39m,
  sqlError: �[33mfalse�[39m,
  attention: �[33mfalse�[39m,
  serverError: �[33mfalse�[39m,
  rowCount: �[90mundefined�[39m,
  curCmd: �[33m185�[39m }
{ name: �[32m'DONE'�[39m,
  event: �[32m'done'�[39m,
  more: �[33mtrue�[39m,
  sqlError: �[33mfalse�[39m,
  attention: �[33mfalse�[39m,
  serverError: �[33mfalse�[39m,
  rowCount: �[90mundefined�[39m,
  curCmd: �[33m185�[39m }
{ name: �[32m'DONE'�[39m,
  event: �[32m'done'�[39m,
  more: �[33mtrue�[39m,
  sqlError: �[33mfalse�[39m,
  attention: �[33mfalse�[39m,
  serverError: �[33mfalse�[39m,
  rowCount: �[90mundefined�[39m,
  curCmd: �[33m185�[39m }
{ name: �[32m'DONE'�[39m,
  event: �[32m'done'�[39m,
  more: �[33mtrue�[39m,
  sqlError: �[33mfalse�[39m,
  attention: �[33mfalse�[39m,
  serverError: �[33mfalse�[39m,
  rowCount: �[90mundefined�[39m,
  curCmd: �[33m186�[39m }
{ name: �[32m'DONE'�[39m,
  event: �[32m'done'�[39m,
  more: �[33mtrue�[39m,
  sqlError: �[33mfalse�[39m,
  attention: �[33mfalse�[39m,
  serverError: �[33mfalse�[39m,
  rowCount: �[90mundefined�[39m,
  curCmd: �[33m186�[39m }
{ name: �[32m'ENVCHANGE'�[39m,
  type: �[32m'LANGUAGE'�[39m,
  event: �[32m'languageChange'�[39m,
  oldValue: �[32m'us_english'�[39m,
  newValue: �[32m'us_english'�[39m }
{ number: �[33m5703�[39m,
  state: �[33m1�[39m,
  class: �[33m0�[39m,
  message: �[32m'Changed language setting to us_english.'�[39m,
  serverName: �[32m'ML01TOOD02'�[39m,
  procName: �[32m''�[39m,
  lineNumber: �[33m10�[39m,
  name: �[32m'INFO'�[39m,
  event: �[32m'infoMessage'�[39m }
{ name: �[32m'DONE'�[39m,
  event: �[32m'done'�[39m,
  more: �[33mtrue�[39m,
  sqlError: �[33mfalse�[39m,
  attention: �[33mfalse�[39m,
  serverError: �[33mfalse�[39m,
  rowCount: �[90mundefined�[39m,
  curCmd: �[33m249�[39m }
{ name: �[32m'DONE'�[39m,
  event: �[32m'done'�[39m,
  more: �[33mtrue�[39m,
  sqlError: �[33mfalse�[39m,
  attention: �[33mfalse�[39m,
  serverError: �[33mfalse�[39m,
  rowCount: �[90mundefined�[39m,
  curCmd: �[33m249�[39m }
{ name: �[32m'DONE'�[39m,
  event: �[32m'done'�[39m,
  more: �[33mtrue�[39m,
  sqlError: �[33mfalse�[39m,
  attention: �[33mfalse�[39m,
  serverError: �[33mfalse�[39m,
  rowCount: �[90mundefined�[39m,
  curCmd: �[33m249�[39m }
{ name: �[32m'DONE'�[39m,
  event: �[32m'done'�[39m,
  more: �[33mfalse�[39m,
  sqlError: �[33mfalse�[39m,
  attention: �[33mfalse�[39m,
  serverError: �[33mfalse�[39m,
  rowCount: �[90mundefined�[39m,
  curCmd: �[33m249�[39m }
State change: LoggedInSendingInitialSql -> LoggedIn

Sent
  type:0x03(RPC_REQUEST), status:0x01(EOM), length:0x00F8, spid:0x0000, packetId:0x01, window:0x00
  0000  16000000 12000000 02000000 00000000 00000100 00000D00 73007000 5F006500  ........ ........ ........ s.p._.e.
  0020  78006500 63007500 74006500 73007100 6C000000 0A400073 00740061 00740065  x.e.c.u. t.e.s.q. l....@.s.t.a.t.e
  0040  006D0065 006E0074 0000E7A0 0F000000 00008200 53004500 4C004500 43005400  .m.e.n.t........ ....S.E. L.E.C.T.
  0060  20005400 4F005000 20003100 35002000 2A002000 46005200 4F004D00 20004F00   .T.O.P.  .1.5. . *. .F.R. O.M. .O.
  0080  4D005300 5F004300 4F005500 4E005400 52005900 20005700 48004500 52004500  M.S._.C. O.U.N.T. R.Y. .W. H.E.R.E.
  00A0  20005500 50005000 45005200 28004E00 41004D00 45002900 20004C00 49004B00   .U.P.P. E.R.(.N. A.M.E.).  .L.I.K.
  00C0  45002000 27002004 1E042104 21041804 2F042500 27000740 00700061 00720061  E. .'. . ..!.!... /.%.'..@.p.a.r.a
  00E0  006D0073 0000E7A0 0F000000 00000000   .m.s.... ........ 
  RPC Request - sp_executesql
State change: LoggedIn -> SentClientRequest

Received
  type:0x04(TABULAR_RESULT), status:0x01(EOM), length:0x013A, spid:0x004A, packetId:0x01, window:0x00
  0000  81070000 00000008 00380E4F 004D0053 005F0043 004F0055 004E0054 00520059  ........ .8.O.M.S._.C.O.U.N.T.R.Y
  0020  005F0049 00440000 00000009 00A70A00 0904D000 6A044300 4F004400 45000000  ._.I.D.. ........ ....j.C. O.D.E...
  0040  00000900 A7640009 04D0006A 044E0041 004D0045 00000000 0009006F 080F4B00  .....d.. ...j.N.A.M.E.... ...o..K.
  0060  52004E00 5F004300 52004500 41005400 45005F00 44004100 54004500 00000000  R.N._.C. R.E.A.T. E._.D.A. T.E.....
  0080  09002604 124B0052 004E005F 00430052 00450041 00540045 005F0055 00530045  ..&..K.R.N._.C.R.E.A.T.E._.U.S.E
  00A0  0052005F 00490044 00000000 0009006F 080F4B00 52004E00 5F004D00 4F004400  .R._.I.D.......o..K.R.N. _.M.O.D.
  00C0  49004600 59005F00 44004100 54004500 00000000 09002604 124B0052 004E005F  I.F.Y._. D.A.T.E. ......&. .K.R.N._
  00E0  004D004F 00440049 00460059 005F0055 00530045 0052005F 00490044 00D11700  .M.O.D.I.F.Y._.U.S.E.R._.I.D....
  0100  00000300 36343306 00D0EEF1 F1E8FF00 000000FF 1100C100 01000000 00000000  ....643. ........ ........ ........
  0120  79000000 00FE0000 E0000000 00000000 0000  y....... ........ ..
{ name: �[32m'COLMETADATA'�[39m,
  event: �[32m'columnMetadata'�[39m,
  columns: 
   [ { userType: �[33m0�[39m,
       flags: �[33m8�[39m,
       type: 
        { type: �[32m'INT4'�[39m,
          name: �[32m'Int'�[39m,
          declaration: �[36m[Function]�[39m,
          writeParameterData: �[36m[Function]�[39m,
          id: �[33m56�[39m },
       colName: �[32m'OMS_COUNTRY_ID'�[39m,
       collation: �[90mundefined�[39m,
       precision: �[90mundefined�[39m,
       scale: �[90mundefined�[39m,
       dataLength: �[90mundefined�[39m,
       tableName: �[90mundefined�[39m },
     { userType: �[33m0�[39m,
       flags: �[33m9�[39m,
       type: 
        { type: �[32m'BIGVARCHR'�[39m,
          name: �[32m'VarChar'�[39m,
          hasCollation: �[33mtrue�[39m,
          dataLengthLength: �[33m2�[39m,
          maximumLength: �[33m8000�[39m,
          declaration: �[36m[Function]�[39m,
          writeParameterData: �[36m[Function]�[39m,
          id: �[33m167�[39m },
       colName: �[32m'CODE'�[39m,
       collation: 
        { lcid: �[33m1033�[39m,
          codepage: �[32m'WINDOWS-1252'�[39m,
          flags: �[33m208�[39m,
          version: �[33m0�[39m,
          sortId: �[33m106�[39m },
       precision: �[90mundefined�[39m,
       scale: �[90mundefined�[39m,
       dataLength: �[33m10�[39m,
       tableName: �[90mundefined�[39m },
     { userType: �[33m0�[39m,
       flags: �[33m9�[39m,
       type: 
        { type: �[32m'BIGVARCHR'�[39m,
          name: �[32m'VarChar'�[39m,
          hasCollation: �[33mtrue�[39m,
          dataLengthLength: �[33m2�[39m,
          maximumLength: �[33m8000�[39m,
          declaration: �[36m[Function]�[39m,
          writeParameterData: �[36m[Function]�[39m,
          id: �[33m167�[39m },
       colName: �[32m'NAME'�[39m,
       collation: 
        { lcid: �[33m1033�[39m,
          codepage: �[32m'WINDOWS-1252'�[39m,
          flags: �[33m208�[39m,
          version: �[33m0�[39m,
          sortId: �[33m106�[39m },
       precision: �[90mundefined�[39m,
       scale: �[90mundefined�[39m,
       dataLength: �[33m100�[39m,
       tableName: �[90mundefined�[39m },
     { userType: �[33m0�[39m,
       flags: �[33m9�[39m,
       type: 
        { type: �[32m'DATETIMN'�[39m,
          name: �[32m'DateTimeN'�[39m,
          dataLengthLength: �[33m1�[39m,
          id: �[33m111�[39m },
       colName: �[32m'KRN_CREATE_DATE'�[39m,
       collation: �[90mundefined�[39m,
       precision: �[90mundefined�[39m,
       scale: �[90mundefined�[39m,
       dataLength: �[33m8�[39m,
       tableName: �[90mundefined�[39m },
     { userType: �[33m0�[39m,
       flags: �[33m9�[39m,
       type: 
        { type: �[32m'INTN'�[39m,
          name: �[32m'IntN'�[39m,
          dataLengthLength: �[33m1�[39m,
          id: �[33m38�[39m },
       colName: �[32m'KRN_CREATE_USER_ID'�[39m,
       collation: �[90mundefined�[39m,
       precision: �[90mundefined�[39m,
       scale: �[90mundefined�[39m,
       dataLength: �[33m4�[39m,
       tableName: �[90mundefined�[39m },
     { userType: �[33m0�[39m,
       flags: �[33m9�[39m,
       type: 
        { type: �[32m'DATETIMN'�[39m,
          name: �[32m'DateTimeN'�[39m,
          dataLengthLength: �[33m1�[39m,
          id: �[33m111�[39m },
       colName: �[32m'KRN_MODIFY_DATE'�[39m,
       collation: �[90mundefined�[39m,
       precision: �[90mundefined�[39m,
       scale: �[90mundefined�[39m,
       dataLength: �[33m8�[39m,
       tableName: �[90mundefined�[39m },
     { userType: �[33m0�[39m,
       flags: �[33m9�[39m,
       type: 
        { type: �[32m'INTN'�[39m,
          name: �[32m'IntN'�[39m,
          dataLengthLength: �[33m1�[39m,
          id: �[33m38�[39m },
       colName: �[32m'KRN_MODIFY_USER_ID'�[39m,
       collation: �[90mundefined�[39m,
       precision: �[90mundefined�[39m,
       scale: �[90mundefined�[39m,
       dataLength: �[33m4�[39m,
       tableName: �[90mundefined�[39m },
     OMS_COUNTRY_ID: { userType: �[33m0�[39m,
       flags: �[33m8�[39m,
       type: 
        { type: �[32m'INT4'�[39m,
          name: �[32m'Int'�[39m,
          declaration: �[36m[Function]�[39m,
          writeParameterData: �[36m[Function]�[39m,
          id: �[33m56�[39m },
       colName: �[32m'OMS_COUNTRY_ID'�[39m,
       collation: �[90mundefined�[39m,
       precision: �[90mundefined�[39m,
       scale: �[90mundefined�[39m,
       dataLength: �[90mundefined�[39m,
       tableName: �[90mundefined�[39m },
     CODE: { userType: �[33m0�[39m,
       flags: �[33m9�[39m,
       type: 
        { type: �[32m'BIGVARCHR'�[39m,
          name: �[32m'VarChar'�[39m,
          hasCollation: �[33mtrue�[39m,
          dataLengthLength: �[33m2�[39m,
          maximumLength: �[33m8000�[39m,
          declaration: �[36m[Function]�[39m,
          writeParameterData: �[36m[Function]�[39m,
          id: �[33m167�[39m },
       colName: �[32m'CODE'�[39m,
       collation: 
        { lcid: �[33m1033�[39m,
          codepage: �[32m'WINDOWS-1252'�[39m,
          flags: �[33m208�[39m,
          version: �[33m0�[39m,
          sortId: �[33m106�[39m },
       precision: �[90mundefined�[39m,
       scale: �[90mundefined�[39m,
       dataLength: �[33m10�[39m,
       tableName: �[90mundefined�[39m },
     NAME: { userType: �[33m0�[39m,
       flags: �[33m9�[39m,
       type: 
        { type: �[32m'BIGVARCHR'�[39m,
          name: �[32m'VarChar'�[39m,
          hasCollation: �[33mtrue�[39m,
          dataLengthLength: �[33m2�[39m,
          maximumLength: �[33m8000�[39m,
          declaration: �[36m[Function]�[39m,
          writeParameterData: �[36m[Function]�[39m,
          id: �[33m167�[39m },
       colName: �[32m'NAME'�[39m,
       collation: 
        { lcid: �[33m1033�[39m,
          codepage: �[32m'WINDOWS-1252'�[39m,
          flags: �[33m208�[39m,
          version: �[33m0�[39m,
          sortId: �[33m106�[39m },
       precision: �[90mundefined�[39m,
       scale: �[90mundefined�[39m,
       dataLength: �[33m100�[39m,
       tableName: �[90mundefined�[39m },
     KRN_CREATE_DATE: { userType: �[33m0�[39m,
       flags: �[33m9�[39m,
       type: 
        { type: �[32m'DATETIMN'�[39m,
          name: �[32m'DateTimeN'�[39m,
          dataLengthLength: �[33m1�[39m,
          id: �[33m111�[39m },
       colName: �[32m'KRN_CREATE_DATE'�[39m,
       collation: �[90mundefined�[39m,
       precision: �[90mundefined�[39m,
       scale: �[90mundefined�[39m,
       dataLength: �[33m8�[39m,
       tableName: �[90mundefined�[39m },
     KRN_CREATE_USER_ID: { userType: �[33m0�[39m,
       flags: �[33m9�[39m,
       type: 
        { type: �[32m'INTN'�[39m,
          name: �[32m'IntN'�[39m,
          dataLengthLength: �[33m1�[39m,
          id: �[33m38�[39m },
       colName: �[32m'KRN_CREATE_USER_ID'�[39m,
       collation: �[90mundefined�[39m,
       precision: �[90mundefined�[39m,
       scale: �[90mundefined�[39m,
       dataLength: �[33m4�[39m,
       tableName: �[90mundefined�[39m },
     KRN_MODIFY_DATE: { userType: �[33m0�[39m,
       flags: �[33m9�[39m,
       type: 
        { type: �[32m'DATETIMN'�[39m,
          name: �[32m'DateTimeN'�[39m,
          dataLengthLength: �[33m1�[39m,
          id: �[33m111�[39m },
       colName: �[32m'KRN_MODIFY_DATE'�[39m,
       collation: �[90mundefined�[39m,
       precision: �[90mundefined�[39m,
       scale: �[90mundefined�[39m,
       dataLength: �[33m8�[39m,
       tableName: �[90mundefined�[39m },
     KRN_MODIFY_USER_ID: { userType: �[33m0�[39m,
       flags: �[33m9�[39m,
       type: 
        { type: �[32m'INTN'�[39m,
          name: �[32m'IntN'�[39m,
          dataLengthLength: �[33m1�[39m,
          id: �[33m38�[39m },
       colName: �[32m'KRN_MODIFY_USER_ID'�[39m,
       collation: �[90mundefined�[39m,
       precision: �[90mundefined�[39m,
       scale: �[90mundefined�[39m,
       dataLength: �[33m4�[39m,
       tableName: �[90mundefined�[39m } ] }
{ name: �[32m'ROW'�[39m,
  event: �[32m'row'�[39m,
  columns: 
   [ { value: �[33m23�[39m,
       metadata: 
        { userType: �[33m0�[39m,
          flags: �[33m8�[39m,
          type: 
           { type: �[32m'INT4'�[39m,
             name: �[32m'Int'�[39m,
             declaration: �[36m[Function]�[39m,
             writeParameterData: �[36m[Function]�[39m,
             id: �[33m56�[39m },
          colName: �[32m'OMS_COUNTRY_ID'�[39m,
          collation: �[90mundefined�[39m,
          precision: �[90mundefined�[39m,
          scale: �[90mundefined�[39m,
          dataLength: �[90mundefined�[39m,
          tableName: �[90mundefined�[39m } },
     { value: �[32m'643'�[39m,
       metadata: 
        { userType: �[33m0�[39m,
          flags: �[33m9�[39m,
          type: 
           { type: �[32m'BIGVARCHR'�[39m,
             name: �[32m'VarChar'�[39m,
             hasCollation: �[33mtrue�[39m,
             dataLengthLength: �[33m2�[39m,
             maximumLength: �[33m8000�[39m,
             declaration: �[36m[Function]�[39m,
             writeParameterData: �[36m[Function]�[39m,
             id: �[33m167�[39m },
          colName: �[32m'CODE'�[39m,
          collation: 
           { lcid: �[33m1033�[39m,
             codepage: �[32m'WINDOWS-1252'�[39m,
             flags: �[33m208�[39m,
             version: �[33m0�[39m,
             sortId: �[33m106�[39m },
          precision: �[90mundefined�[39m,
          scale: �[90mundefined�[39m,
          dataLength: �[33m10�[39m,
          tableName: �[90mundefined�[39m } },
     { value: �[32m'Ðîññèÿ'�[39m,
       metadata: 
        { userType: �[33m0�[39m,
          flags: �[33m9�[39m,
          type: 
           { type: �[32m'BIGVARCHR'�[39m,
             name: �[32m'VarChar'�[39m,
             hasCollation: �[33mtrue�[39m,
             dataLengthLength: �[33m2�[39m,
             maximumLength: �[33m8000�[39m,
             declaration: �[36m[Function]�[39m,
             writeParameterData: �[36m[Function]�[39m,
             id: �[33m167�[39m },
          colName: �[32m'NAME'�[39m,
          collation: 
           { lcid: �[33m1033�[39m,
             codepage: �[32m'WINDOWS-1252'�[39m,
             flags: �[33m208�[39m,
             version: �[33m0�[39m,
             sortId: �[33m106�[39m },
          precision: �[90mundefined�[39m,
          scale: �[90mundefined�[39m,
          dataLength: �[33m100�[39m,
          tableName: �[90mundefined�[39m } },
     { value: �[1mnull�[22m,
       metadata: 
        { userType: �[33m0�[39m,
          flags: �[33m9�[39m,
          type: 
           { type: �[32m'DATETIMN'�[39m,
             name: �[32m'DateTimeN'�[39m,
             dataLengthLength: �[33m1�[39m,
             id: �[33m111�[39m },
          colName: �[32m'KRN_CREATE_DATE'�[39m,
          collation: �[90mundefined�[39m,
          precision: �[90mundefined�[39m,
          scale: �[90mundefined�[39m,
          dataLength: �[33m8�[39m,
          tableName: �[90mundefined�[39m } },
     { value: �[1mnull�[22m,
       metadata: 
        { userType: �[33m0�[39m,
          flags: �[33m9�[39m,
          type: 
           { type: �[32m'INTN'�[39m,
             name: �[32m'IntN'�[39m,
             dataLengthLength: �[33m1�[39m,
             id: �[33m38�[39m },
          colName: �[32m'KRN_CREATE_USER_ID'�[39m,
          collation: �[90mundefined�[39m,
          precision: �[90mundefined�[39m,
          scale: �[90mundefined�[39m,
          dataLength: �[33m4�[39m,
          tableName: �[90mundefined�[39m } },
     { value: �[1mnull�[22m,
       metadata: 
        { userType: �[33m0�[39m,
          flags: �[33m9�[39m,
          type: 
           { type: �[32m'DATETIMN'�[39m,
             name: �[32m'DateTimeN'�[39m,
             dataLengthLength: �[33m1�[39m,
             id: �[33m111�[39m },
          colName: �[32m'KRN_MODIFY_DATE'�[39m,
          collation: �[90mundefined�[39m,
          precision: �[90mundefined�[39m,
          scale: �[90mundefined�[39m,
          dataLength: �[33m8�[39m,
          tableName: �[90mundefined�[39m } },
     { value: �[1mnull�[22m,
       metadata: 
        { userType: �[33m0�[39m,
          flags: �[33m9�[39m,
          type: 
           { type: �[32m'INTN'�[39m,
             name: �[32m'IntN'�[39m,
             dataLengthLength: �[33m1�[39m,
             id: �[33m38�[39m },
          colName: �[32m'KRN_MODIFY_USER_ID'�[39m,
          collation: �[90mundefined�[39m,
          precision: �[90mundefined�[39m,
          scale: �[90mundefined�[39m,
          dataLength: �[33m4�[39m,
          tableName: �[90mundefined�[39m } },
     OMS_COUNTRY_ID: { value: �[33m23�[39m,
       metadata: 
        { userType: �[33m0�[39m,
          flags: �[33m8�[39m,
          type: 
           { type: �[32m'INT4'�[39m,
             name: �[32m'Int'�[39m,
             declaration: �[36m[Function]�[39m,
             writeParameterData: �[36m[Function]�[39m,
             id: �[33m56�[39m },
          colName: �[32m'OMS_COUNTRY_ID'�[39m,
          collation: �[90mundefined�[39m,
          precision: �[90mundefined�[39m,
          scale: �[90mundefined�[39m,
          dataLength: �[90mundefined�[39m,
          tableName: �[90mundefined�[39m } },
     CODE: { value: �[32m'643'�[39m,
       metadata: 
        { userType: �[33m0�[39m,
          flags: �[33m9�[39m,
          type: 
           { type: �[32m'BIGVARCHR'�[39m,
             name: �[32m'VarChar'�[39m,
             hasCollation: �[33mtrue�[39m,
             dataLengthLength: �[33m2�[39m,
             maximumLength: �[33m8000�[39m,
             declaration: �[36m[Function]�[39m,
             writeParameterData: �[36m[Function]�[39m,
             id: �[33m167�[39m },
          colName: �[32m'CODE'�[39m,
          collation: 
           { lcid: �[33m1033�[39m,
             codepage: �[32m'WINDOWS-1252'�[39m,
             flags: �[33m208�[39m,
             version: �[33m0�[39m,
             sortId: �[33m106�[39m },
          precision: �[90mundefined�[39m,
          scale: �[90mundefined�[39m,
          dataLength: �[33m10�[39m,
          tableName: �[90mundefined�[39m } },
     NAME: { value: �[32m'Ðîññèÿ'�[39m,
       metadata: 
        { userType: �[33m0�[39m,
          flags: �[33m9�[39m,
          type: 
           { type: �[32m'BIGVARCHR'�[39m,
             name: �[32m'VarChar'�[39m,
             hasCollation: �[33mtrue�[39m,
             dataLengthLength: �[33m2�[39m,
             maximumLength: �[33m8000�[39m,
             declaration: �[36m[Function]�[39m,
             writeParameterData: �[36m[Function]�[39m,
             id: �[33m167�[39m },
          colName: �[32m'NAME'�[39m,
          collation: 
           { lcid: �[33m1033�[39m,
             codepage: �[32m'WINDOWS-1252'�[39m,
             flags: �[33m208�[39m,
             version: �[33m0�[39m,
             sortId: �[33m106�[39m },
          precision: �[90mundefined�[39m,
          scale: �[90mundefined�[39m,
          dataLength: �[33m100�[39m,
          tableName: �[90mundefined�[39m } },
     KRN_CREATE_DATE: { value: �[1mnull�[22m,
       metadata: 
        { userType: �[33m0�[39m,
          flags: �[33m9�[39m,
          type: 
           { type: �[32m'DATETIMN'�[39m,
             name: �[32m'DateTimeN'�[39m,
             dataLengthLength: �[33m1�[39m,
             id: �[33m111�[39m },
          colName: �[32m'KRN_CREATE_DATE'�[39m,
          collation: �[90mundefined�[39m,
          precision: �[90mundefined�[39m,
          scale: �[90mundefined�[39m,
          dataLength: �[33m8�[39m,
          tableName: �[90mundefined�[39m } },
     KRN_CREATE_USER_ID: { value: �[1mnull�[22m,
       metadata: 
        { userType: �[33m0�[39m,
          flags: �[33m9�[39m,
          type: 
           { type: �[32m'INTN'�[39m,
             name: �[32m'IntN'�[39m,
             dataLengthLength: �[33m1�[39m,
             id: �[33m38�[39m },
          colName: �[32m'KRN_CREATE_USER_ID'�[39m,
          collation: �[90mundefined�[39m,
          precision: �[90mundefined�[39m,
          scale: �[90mundefined�[39m,
          dataLength: �[33m4�[39m,
          tableName: �[90mundefined�[39m } },
     KRN_MODIFY_DATE: { value: �[1mnull�[22m,
       metadata: 
        { userType: �[33m0�[39m,
          flags: �[33m9�[39m,
          type: 
           { type: �[32m'DATETIMN'�[39m,
             name: �[32m'DateTimeN'�[39m,
             dataLengthLength: �[33m1�[39m,
             id: �[33m111�[39m },
          colName: �[32m'KRN_MODIFY_DATE'�[39m,
          collation: �[90mundefined�[39m,
          precision: �[90mundefined�[39m,
          scale: �[90mundefined�[39m,
          dataLength: �[33m8�[39m,
          tableName: �[90mundefined�[39m } },
     KRN_MODIFY_USER_ID: { value: �[1mnull�[22m,
       metadata: 
        { userType: �[33m0�[39m,
          flags: �[33m9�[39m,
          type: 
           { type: �[32m'INTN'�[39m,
             name: �[32m'IntN'�[39m,
             dataLengthLength: �[33m1�[39m,
             id: �[33m38�[39m },
          colName: �[32m'KRN_MODIFY_USER_ID'�[39m,
          collation: �[90mundefined�[39m,
          precision: �[90mundefined�[39m,
          scale: �[90mundefined�[39m,
          dataLength: �[33m4�[39m,
          tableName: �[90mundefined�[39m } } ] }
have a row event!
{ name: �[32m'DONEINPROC'�[39m,
  event: �[32m'doneInProc'�[39m,
  more: �[33mtrue�[39m,
  sqlError: �[33mfalse�[39m,
  attention: �[33mfalse�[39m,
  serverError: �[33mfalse�[39m,
  rowCount: �[33m1�[39m,
  curCmd: �[33m193�[39m }
{ name: �[32m'RETURNSTATUS'�[39m,
  event: �[32m'returnStatus'�[39m,
  value: �[33m0�[39m }
{ name: �[32m'DONEPROC'�[39m,
  event: �[32m'doneProc'�[39m,
  more: �[33mfalse�[39m,
  sqlError: �[33mfalse�[39m,
  attention: �[33mfalse�[39m,
  serverError: �[33mfalse�[39m,
  rowCount: �[90mundefined�[39m,
  curCmd: �[33m224�[39m }
State change: SentClientRequest -> LoggedIn
done rowCount=1
State change: LoggedIn -> Final
connection to 192.168.0.232:1433 closed
State change: Final -> Final

@patriksimek
Copy link
Collaborator

I missed one thing in your code... I believe the problem is that you're calling you mcb callback twice... once form the row event handler and once from new Request handler. You should only call it from new Request handler because row event is emitted for each row in a recordset.

@drudrum
Copy link
Author

drudrum commented Apr 3, 2014

I am processing rows, and finish in one place(mcb), like a -->

tdb.query('SELECT TOP 100 * FROM PATIENTS ORDER BY PATIENTS_ID DESC',{},function(err,row){
  if (err) 
    return res.end(String(err));

  if (row) {
    data.push(row);
    return null;
  }

  res.render('defaultTable',{
    rows:data
  });
  return null;
});//query

@patriksimek
Copy link
Collaborator

I'am out of ideas here, I'am quite sure changing the ucs2 parameter doesn't change anything internally because there is a default value for it - ucs2.

@drudrum drudrum closed this Apr 23, 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

Successfully merging this pull request may close these issues.

None yet

2 participants