简体   繁体   中英

Can't set msnodesql to work

Ok, i've tryed everything here. I did installed msnodesql from

- https://github.com/Azure/node-sqlserver

and

- http://www.microsoft.com/en-us/download/details.aspx?id=29995

following every line of instruction on installation. build with node-gyp... everything.

Then when I do something like:

var conn_str = "Driver={SQL Server Native Client 11.0};Server={(local)\\SQLEXPRESS};Database={DBName};Trusted_Connection={Yes};";
var stmt = sqlserver.query(conn_str, "SELECT * from av.CLIENT");
stmt.on('meta', function (meta) { console.log("We've received the metadata"); });
stmt.on('row', function (idx) { console.log("We've started receiving a row"); });
stmt.on('column', function (idx, data, more) { console.log(idx + ":" + data); });
stmt.on('done', function () { console.log("All done!"); });
stmt.on('error', function (err) { console.log("We had an error :-( " + err); });

it throws me an error on node console:

[Error: [msnodesql] Invalid passed to function query. Type should be .]

What drives me crazy is that it should be something like:

[Error: [msnodesql] Invalid --SOMETHING-- passed to function query. Type should be --SOMETHING_ELSE--.]

right?

It doesn't even pass through the stmt.on('error', line

I've repeated the installation steps over and over, thinking that maybe there was an error in the building process, but nothing.!

I'm using Windows 8 x64 and node v-0.10 (I wonder if that driver is ment to be use ONLY with node v.0.8 <

I need help. pls.

I have not used node-sqlserver, but I have used tedious and it worked well. Give that a try, maybe you'll have better luck?

Ok. I just found out why it gives errors like Error: [msnodesql] Invalid passed to function query. Type should be .] .

If you happen to have a prototype over the Array object, it will throw this kind of errors. For example, I have a prototype function over the Array class called "indexOfObject".....

To be more specific, there's a file in msnodesql > lib > sql.js , in it there's a function called validateParameters.

In there, I changed this:

if ( typeof parameters[p].value != parameters[p].type ) 

for this:

if ( typeof parameters[p].value != parameters[p].type && parameters[p].name ) 

it may not be overthinked as a solution to all my problems, but at least everything works fine from there on.!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM