node-mssql

connect to sql server 2012 with node.js

[亡魂溺海] 提交于 2019-12-11 23:50:43
问题 I want to connect a sql db with node, so i find this npm package https://www.npmjs.com/package/mssql I'am looking forward to create a simple authentication so for a start i just want to connect to the sql db, so my problem is when i tried to execute the existing code in mssql documentation i get an error here is what i executed : var sql = require('mssql'); var config = { user: '...', password: '...', server: 'localhost', database: 'dbUsers' } sql.connect(config, function(err) { throw err; //

How to access the output parameter in node mssql?

纵饮孤独 提交于 2019-12-11 13:53:20
问题 ` request.input('xyz',sql.Int,1); request.input('abc',sql.Numeric,2); request.output('pqr',sql.Int); request.output('def',sql.Char); request.execute('[StoredProcedure]',function(err,recordsets,returnvalue){ next.ifError(err); console.log(returnvalue); })` Now the problem is how will i access the output parameters. Regards. 回答1: request.parameters.pqr.value and request.parameters.def.value Got the answer , so sharing it :) 回答2: Actually the method described above did not work for me using

Can't get Node mssql to work properly

爱⌒轻易说出口 提交于 2019-12-11 06:01:40
问题 This is the way I'm using mssql at the moment but it gives sometimes errors: JavaScript: router.get('/academiejaren', (req, res) => { sql.connect(dbconfig, function (err) { var request = new sql.Request(); if (err) { console.log(err); return; } request.query("SELECT * FROM [Alg].[DefAJ];", function (err, recordset) { if (err) { console.log(err); return; } else { res.end(JSON.stringify(recordset)); } }); request.query(); }); }); Error: { ConnectionError: Connection is closed. at C:\Users\Milan

nodejs mmsql bulk insert to temp table

a 夏天 提交于 2019-12-08 08:16:38
问题 I'm using mssql to connect to sql server 2012 with node.js. I've discovered the bulk insert option in the docs I'm wanting to insert data into a temporary table, which the doc says I can do. Here is what I'm trying: createConnection(config.dbConfig); var table = new sql.Table('#atable'); table.create = true; table.columns.add('a', sql.Int, { nullable: false}); table.rows.add(1); table.rows.add(2); table.rows.add(3); var request = new sql.Request(); request.bulk(table, function(err, rowCount){

Why does async/await version of my transactional mssql app fail but callbacks version works?

风格不统一 提交于 2019-12-07 23:58:18
问题 To illuminate the problem I'm having getting a nodejs/mssql application working, I've attempted to code two functionally equivalent versions of a simple (prepared) INSERT statement wrapped in a transaction. The callbacks version works - inserts a row into my Sql Server db. The async / await version throws an error - TransactionError: Can't commit transaction. There is a request in progress. I have tried many variations of the failing version (statement reordering where plausible), but the

nodejs mmsql bulk insert to temp table

懵懂的女人 提交于 2019-12-07 15:49:32
I'm using mssql to connect to sql server 2012 with node.js. I've discovered the bulk insert option in the docs I'm wanting to insert data into a temporary table, which the doc says I can do. Here is what I'm trying: createConnection(config.dbConfig); var table = new sql.Table('#atable'); table.create = true; table.columns.add('a', sql.Int, { nullable: false}); table.rows.add(1); table.rows.add(2); table.rows.add(3); var request = new sql.Request(); request.bulk(table, function(err, rowCount){ if(err){ console.log('bulk insert error'); console.log(err); } var taco = new sql.Request(); taco

Why does async/await version of my transactional mssql app fail but callbacks version works?

╄→尐↘猪︶ㄣ 提交于 2019-12-06 12:20:16
To illuminate the problem I'm having getting a nodejs/mssql application working, I've attempted to code two functionally equivalent versions of a simple (prepared) INSERT statement wrapped in a transaction. The callbacks version works - inserts a row into my Sql Server db. The async / await version throws an error - TransactionError: Can't commit transaction. There is a request in progress. I have tried many variations of the failing version (statement reordering where plausible), but the version included below is the version that most closely mimics the logic of the working, callbacks version

Errors with node-mssql in a webpack-bundled React app

三世轮回 提交于 2019-12-01 23:15:44
问题 My React app fails to build whenever I try to use the node-mssql library. It's important that I do this on the client side, since I have to serve this app from an old IIS server. It seems that executing in Webpack browser bundle requires additional configuration. Some kind of Polyfill maybe? I can't find any help on this anywhere -- I could really use some advice. The build errors and warning are: WARNING in ./~/mssql/lib/tds-fix.js Module not found: Error: Cannot resolve module 'tds/package

Errors with node-mssql in a webpack-bundled React app

孤街浪徒 提交于 2019-12-01 21:42:57
My React app fails to build whenever I try to use the node-mssql library. It's important that I do this on the client side, since I have to serve this app from an old IIS server. It seems that executing in Webpack browser bundle requires additional configuration. Some kind of Polyfill maybe? I can't find any help on this anywhere -- I could really use some advice. The build errors and warning are: WARNING in ./~/mssql/lib/tds-fix.js Module not found: Error: Cannot resolve module 'tds/package.json' in /Users/hills/upload-covers/node_modules/mssql/lib @ ./~/mssql/lib/tds-fix.js 6:8-35 WARNING in

Node.js MSSQL tedius ConnectionError: Failed to connect to localhost:1433 - connect ECONNREFUSED

故事扮演 提交于 2019-11-28 07:10:38
I am trying to connect to MSSQL 2012 using NodeJS with the mssql connection interface. When attempting to connect I get the following error: { [ConnectionError: Failed to connect to localhost:1433 - connect ECONNREFUSED] name: 'ConnectionError', message: 'Failed to conncet to localhost:1433 - connect ECONNREFUSED', code: 'ESOCKET' } Any ideas on how to fix this? The solution is to enable TCP connections which are disabled by default. My case wasn't exactly the same as Matt's, but his screenshot was enough to remember me what was missing. As it is said here , when you are using the SQL Server