-1

I am using this module tedious to connect. I am having issues when I try to populate a collection with the data from MSSQL.

My code thus far:

http://pastebin.com/q4ByRCbW

Meteor.startup(function () {

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

    var config = {
        userName: 'xxxxx',
        password: 'xxxx',
        server: '197.xxx.xxx.xxx',

        // If you're on Windows Azure, you will need this:
        options: {
            encrypt: true,
            debug: {
                packet: true,
                data: true,
                payload: true,
                token: false,
                log: true
            }
        }
    };

    var connection = new Connection(config);
    var asnycWrapFunc = Async.wrap(connection.execSql);
    var rettarr = [];

    function executeStatement() {
        Fiber(function(){
            request = new Request("select * from AccountSummary", function(err, rowCount) {
              if (err) {
                console.log(err);
              } else {
                console.log(rowCount + ' rows');
              }
            });
        request.on('row', function(columns) {
            aaary = []; cnting = 0;
            columns.forEach(function(column) {
                console.log(column.value);
                aaary.push(column.value);
            });
            if (AccountSummary.find().count() === 0){
                AccountSummary.insert({ID:aaary[0], ClientNo:aaary[1], ClientName:aaary[2]});
            }

        });
         //rettarr.push(aaary);
        }).run();

        asnycWrapFunc(request);
        //return rettarr;
    }

    connection.on('connect', function(err) {
        // If no error, then good to go...
          var res = executeStatement();
          // aaary = res[0];

          console.log(res);
          errr  = err;
    });
});
nikoshr
  • 32,926
  • 33
  • 91
  • 105
  • 1
    What kind of issues? What's the question? Please post the relevant part of code here, state what you expected to achieve and what you got. – Hubert OG May 08 '14 at 10:39
  • Welcome to SO. Please don't rely on external websites to host your code, include the relevant parts in your question instead. And it's still missing the issues you have, edit your question to add details and make it the clearest you can. – nikoshr May 08 '14 at 11:55
  • i pasted the code in pastebin. http://pastebin.com/q4ByRCbW. I am getting errors ranging from Fiber not defined to Meteor code must always run within a Fiber. I just want someone to tell how to correctly wrap Tedious functions in meteor so that i will get those errors – user1863492 May 08 '14 at 12:07
  • errors: http://postimg.org/image/96uvyrfqn/ – user1863492 May 08 '14 at 12:16

1 Answers1

1

I have found that you have to use Future if you want to you a package like Tedious.

This mini tutorial has the answer