Advertisement
tapiwa

Untitled

May 12th, 2014
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Meteor.startup(function () {
  2.  
  3.     var Request = Npm.require('tedious').Request;
  4.    var  Fiber = Npm.require('fibers');
  5.    arrTest = new Meteor.EnvironmentVariable;
  6.    function insrtInto (dataInfo) {
  7.            
  8.            //var finer = Fiber.current;
  9.            //finer.run (function (){
  10.            // console.log('running.........');
  11.            //    console.log (AccountSummary.find().count());
  12.            /// console.log(dataInfo);
  13.             //return 'yes'
  14.           /// })
  15.          
  16.             // var results = Fiber.yield();
  17.              
  18.              // return results ;
  19.  
  20.         };
  21.  
  22.   function executeStatement() {
  23.     //arrry  = [];
  24.    // Fiber  ( function () {
  25.  
  26.          request = new Request("select * from AccountSummary", function(err, rowCount, rows) {
  27.  
  28.       if (err) {
  29.         console.log(err);
  30.       } else {
  31.         console.log(rowCount + ' rows');
  32.         //arrTest.withValue(rows);
  33.          // Fiber(function(){
  34.          //    insrtInto ( rows);
  35.          // }).run();
  36.        
  37.         // for (var iter = 0; iter < rows.length;iter++  );
  38.  
  39.       }
  40.     });
  41.  
  42.    // }).run();
  43.  
  44.  
  45.     request.on('row', function(columns) {
  46.       columns.forEach(function(column) {
  47.         console.log(column.value);
  48.       });
  49.     });
  50.     // request.on('done', function(rowCount, more, rows) {
  51.     //  console.log("am done");
  52.     //  console.log(rows);
  53.     //  console.log("///end");
  54.     // });
  55.     connection.execSql(request);
  56.     //return   arrry;
  57.   }
  58.  
  59.   var Connection = Npm.require('tedious').Connection;
  60.  
  61.   var config = {
  62.     userName: 'xxxx',
  63.     password: 'xxxxx',
  64.     server: 'xxx.xxx.xxx.xxx',
  65.    
  66.     // If you're on Windows Azure, you will need this:
  67.     options: {encrypt: true,
  68.       //rowCollectionOnDone:true,
  69.       rowCollectionOnRequestCompletion: true,
  70.       debug: {
  71.       packet: true,
  72.       data: true,
  73.       payload: true,
  74.       token: false,
  75.       log: true
  76.     }
  77.   }
  78.   };
  79.  
  80.   var connection = new Connection(config);
  81.    
  82.   connection.on('connect', function(err) {
  83.     // If no error, then good to go...
  84.  
  85.       // var rere = Meteor.bindEnvironment ( function ()
  86.       // {
  87.         executeStatement();
  88.  
  89.       // }, function (e)
  90.       // {
  91.       //   console.log ("error");
  92.       //   throw e;
  93.       // }
  94.  
  95.       //   );
  96.       // AccountSummary.find().count();
  97.       //console.log(rere);
  98.      // errr  = err;
  99.     }
  100.   );
  101.       });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement