Problem with request to SQL Server DB with tediousAdd a column with a default value to an existing table in SQL ServerHow to return only the Date from a SQL Server DateTime datatypeHow to check if a column exists in a SQL Server table?Check if table exists in SQL ServerHow to concatenate text from multiple rows into a single text string in SQL server?LEFT JOIN vs. LEFT OUTER JOIN in SQL ServerInserting multiple rows in a single SQL query?How do I UPDATE from a SELECT in SQL Server?Find all tables containing column with specified name - MS SQL ServerHow to Delete using INNER JOIN with SQL Server?

Floating Point XOR

Why is the car dealer insisting on a loan instead of cash?

Who are the people reviewing far more papers than they're submitting for review?

What if I don't know whether my program will be linked to a GPL library or not?

Amortized Loans seem to benefit the bank more than the customer

What does this Blight Tower UI mean?

Why is the year in this ISO timestamp not 2019?

Writing a system of Linear Equations

Asked to Not Use Transactions and to Use A Workaround to Simulate One

How would you translate Evangelii Nuntiandi?

Unpredictability of Stock Market

What does the "capacitor into resistance" symbol mean?

Is there a tool to measure the "maturity" of a code in Git?

How to convert Mn2O3 to Mn3O4?

Answer Not A Fool, or Answer A Fool?

Output Distinct Factor Cuboids

Very lazy puppy

Why does '/' contain '..'?

What's the benefit of prohibiting the use of techniques/language constructs that have not been taught?

Why does an orbit become hyperbolic when total orbital energy is positive?

Impossible Scrabble Words

In what state are satellites left in when they are left in a graveyard orbit?

Permutations in Disguise

How clean are pets?



Problem with request to SQL Server DB with tedious


Add a column with a default value to an existing table in SQL ServerHow to return only the Date from a SQL Server DateTime datatypeHow to check if a column exists in a SQL Server table?Check if table exists in SQL ServerHow to concatenate text from multiple rows into a single text string in SQL server?LEFT JOIN vs. LEFT OUTER JOIN in SQL ServerInserting multiple rows in a single SQL query?How do I UPDATE from a SELECT in SQL Server?Find all tables containing column with specified name - MS SQL ServerHow to Delete using INNER JOIN with SQL Server?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I am having a problem with sending a simple request to SQL Server, I am using tedious package and I am getting this error:




"RequestError: Requests can only be made in the LoggedIn state, not
the Connecting state".




I got a message that the node has connected to the DB, but after I want to execute select I get this message.



I got two servers:



  1. App server

  2. List item

DB Server



var fs = require("fs");
var Connection = require('tedious').Connection;
var config =
userName: 'xxxx',
password: 'xxxx',
//server: 'xxxx',
server: 'xxxx',
// If you are on Microsoft Azure, you need this:
options: //encrypt: true,
database: 'xxxx'

;
var connection = new Connection(config);
connection.on('connect', function (err)
// If no error, then good to proceed.
console.log("Connected");

connection.on('debug', function (err) console.log('debug:', err); );

executeStatement();
);

var Request = require('tedious').Request;
var TYPES = require('tedious').TYPES;

function executeStatement()
// Provjeravam je li mi se spojio na server:
connection.on('debug', function (err) console.log('debug:', err); );

// funkcija za sustav:

request = new Request('SELECT * FROM NARANOTIFIKACIJEM1;', function (err)
if (err)
console.log(err);
fs.writeFile("temp.txt", err, function (err, data)
if (err) console.log(err);
console.log("Successfully Written to File.");
);

);
var result = "";
request.on('row', function (columns)
columns.forEach(function (column)
if (column.value === null)
console.log('NULL');
else
result += column.value + " ";

);
console.log(result);
result = "";
);

request.on('done', function (rowCount, more)
console.log(rowCount + ' rows returned');
);
connection.execSql(request);










share|improve this question
































    0















    I am having a problem with sending a simple request to SQL Server, I am using tedious package and I am getting this error:




    "RequestError: Requests can only be made in the LoggedIn state, not
    the Connecting state".




    I got a message that the node has connected to the DB, but after I want to execute select I get this message.



    I got two servers:



    1. App server

    2. List item

    DB Server



    var fs = require("fs");
    var Connection = require('tedious').Connection;
    var config =
    userName: 'xxxx',
    password: 'xxxx',
    //server: 'xxxx',
    server: 'xxxx',
    // If you are on Microsoft Azure, you need this:
    options: //encrypt: true,
    database: 'xxxx'

    ;
    var connection = new Connection(config);
    connection.on('connect', function (err)
    // If no error, then good to proceed.
    console.log("Connected");

    connection.on('debug', function (err) console.log('debug:', err); );

    executeStatement();
    );

    var Request = require('tedious').Request;
    var TYPES = require('tedious').TYPES;

    function executeStatement()
    // Provjeravam je li mi se spojio na server:
    connection.on('debug', function (err) console.log('debug:', err); );

    // funkcija za sustav:

    request = new Request('SELECT * FROM NARANOTIFIKACIJEM1;', function (err)
    if (err)
    console.log(err);
    fs.writeFile("temp.txt", err, function (err, data)
    if (err) console.log(err);
    console.log("Successfully Written to File.");
    );

    );
    var result = "";
    request.on('row', function (columns)
    columns.forEach(function (column)
    if (column.value === null)
    console.log('NULL');
    else
    result += column.value + " ";

    );
    console.log(result);
    result = "";
    );

    request.on('done', function (rowCount, more)
    console.log(rowCount + ' rows returned');
    );
    connection.execSql(request);










    share|improve this question




























      0












      0








      0








      I am having a problem with sending a simple request to SQL Server, I am using tedious package and I am getting this error:




      "RequestError: Requests can only be made in the LoggedIn state, not
      the Connecting state".




      I got a message that the node has connected to the DB, but after I want to execute select I get this message.



      I got two servers:



      1. App server

      2. List item

      DB Server



      var fs = require("fs");
      var Connection = require('tedious').Connection;
      var config =
      userName: 'xxxx',
      password: 'xxxx',
      //server: 'xxxx',
      server: 'xxxx',
      // If you are on Microsoft Azure, you need this:
      options: //encrypt: true,
      database: 'xxxx'

      ;
      var connection = new Connection(config);
      connection.on('connect', function (err)
      // If no error, then good to proceed.
      console.log("Connected");

      connection.on('debug', function (err) console.log('debug:', err); );

      executeStatement();
      );

      var Request = require('tedious').Request;
      var TYPES = require('tedious').TYPES;

      function executeStatement()
      // Provjeravam je li mi se spojio na server:
      connection.on('debug', function (err) console.log('debug:', err); );

      // funkcija za sustav:

      request = new Request('SELECT * FROM NARANOTIFIKACIJEM1;', function (err)
      if (err)
      console.log(err);
      fs.writeFile("temp.txt", err, function (err, data)
      if (err) console.log(err);
      console.log("Successfully Written to File.");
      );

      );
      var result = "";
      request.on('row', function (columns)
      columns.forEach(function (column)
      if (column.value === null)
      console.log('NULL');
      else
      result += column.value + " ";

      );
      console.log(result);
      result = "";
      );

      request.on('done', function (rowCount, more)
      console.log(rowCount + ' rows returned');
      );
      connection.execSql(request);










      share|improve this question
















      I am having a problem with sending a simple request to SQL Server, I am using tedious package and I am getting this error:




      "RequestError: Requests can only be made in the LoggedIn state, not
      the Connecting state".




      I got a message that the node has connected to the DB, but after I want to execute select I get this message.



      I got two servers:



      1. App server

      2. List item

      DB Server



      var fs = require("fs");
      var Connection = require('tedious').Connection;
      var config =
      userName: 'xxxx',
      password: 'xxxx',
      //server: 'xxxx',
      server: 'xxxx',
      // If you are on Microsoft Azure, you need this:
      options: //encrypt: true,
      database: 'xxxx'

      ;
      var connection = new Connection(config);
      connection.on('connect', function (err)
      // If no error, then good to proceed.
      console.log("Connected");

      connection.on('debug', function (err) console.log('debug:', err); );

      executeStatement();
      );

      var Request = require('tedious').Request;
      var TYPES = require('tedious').TYPES;

      function executeStatement()
      // Provjeravam je li mi se spojio na server:
      connection.on('debug', function (err) console.log('debug:', err); );

      // funkcija za sustav:

      request = new Request('SELECT * FROM NARANOTIFIKACIJEM1;', function (err)
      if (err)
      console.log(err);
      fs.writeFile("temp.txt", err, function (err, data)
      if (err) console.log(err);
      console.log("Successfully Written to File.");
      );

      );
      var result = "";
      request.on('row', function (columns)
      columns.forEach(function (column)
      if (column.value === null)
      console.log('NULL');
      else
      result += column.value + " ";

      );
      console.log(result);
      result = "";
      );

      request.on('done', function (rowCount, more)
      console.log(rowCount + ' rows returned');
      );
      connection.execSql(request);







      node.js sql-server tedious






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 28 at 13:55







      Dino Filipovic

















      asked Mar 28 at 13:01









      Dino FilipovicDino Filipovic

      3610 bronze badges




      3610 bronze badges

























          0






          active

          oldest

          votes










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );














          draft saved

          draft discarded
















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55398326%2fproblem-with-request-to-sql-server-db-with-tedious%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes




          Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.







          Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.




















          draft saved

          draft discarded















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55398326%2fproblem-with-request-to-sql-server-db-with-tedious%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

          Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript