Display result of a query in an HTML tab. NODE.JS/SQL SERVER

Asked

Viewed 261 times

1

Hello, I need urgent help. I made a connection to the sql server database via Node.js Only to know the amount of items you have in the table (Count). I would like to show this quantity result in a field in an HTML page.

Until now I did so, but it didn’t work.

var sql = require('mssql');
const { Connection } = require('tedious');

var dbconfig = {
    server: "******", 
    user:"******",
    password:"*****",
    database:"db_pocs",
    port:1433, //default port for sql server
    options: {
        encrypt: false // if on windows azure will set to true
    }
};

function getList(){
    var conn = new sql.ConnectionPool(dbconfig);
    conn.connect(function(err) {
        if(err) throw err;
        var req = new sql.Request(conn);
        req.query("select count(ID_atividade) from atividades_func", function(err, recordset) {
            var msg = document.getElementById('num')
            if(err) throw err;
            else
                msg.innerHTML = recordset;
            conn.close(); //close connection
        });
    });
}

window.setInterval("getList()",1000)
<button type="button" class="btn btn-outline-primary btn-lg" onclick="nextPage('carga')">
          <i class="fa fa-caret-square-o-up" style="font-size: 30px"></i>
          <p id="txt-carga">CARGA</p>
          <p class="font-weight-light" id="txt-vc">VC</p>
          <div id="num"></div>
          <p id="vc-carga"></p>
          <p class="font-weight-light" id="txt-td">TD</p>
          <p id="td-carga">25</p>
        </button>

In the image, where the numbers (6,25,44...) filled in the "hand", I want him to bring this information directly from the bank, through select Count.

inserir a descrição da imagem aqui

If you can help me, I’d be most grateful!

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.