Frage

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;
    });
});
War es hilfreich?

Lösung

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

This mini tutorial has the answer

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top