Permalink
Browse files

added example insert using parameters of different types

  • Loading branch information...
willm committed Feb 6, 2013
1 parent e113583 commit ad9af332366adfb34cd33777ca774be784873a00
Showing with 24 additions and 0 deletions.
  1. +24 −0 examples/parameters.js
View
@@ -0,0 +1,24 @@
+var Connection = require('tedious').Connection,
+ Request = require('tedious').Request,
+ TYPES = require('tedious').TYPES;
+
+var connection = new Connection({
+ server: '192.168.1.212',
+ userName: 'test',
+ password: 'test'
+});
+
+connection.on('connect', function(err){
+ var request = new Request("INSERT INTO MyTable (uniqueIdCol, intCol, nVarCharCol) VALUES (@uniqueIdVal, @intVal, @nVarCharVal)",
+ function(err){
+ if(err){
+ console.log(err);
+ };
+ });
+
+ request.addParameter('uniqueIdVal', TYPES.UniqueIdentifierN,'ba46b824-487b-4e7d-8fb9-703acdf954e5');
+ request.addParameter('intVal', TYPES.Int, 435);
+ request.addParameter('nVarCharVal', TYPES.NVarChar, 'hello world');
+
+ connection.execSql(request);
+});

0 comments on commit ad9af33

Please sign in to comment.