Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

185
Views
Nodo Si la instrucción no se activa correctamente

Soy un completo novato en nodos y javascript en general.

Me las arreglé para armar el siguiente script usando algunos tutoriales:

 //HTTP Server var app = require('express')(); var http = require('http').Server(app); //Socket.IO var io = require('socket.io')(http); //MSSQL Server var Connection = require('tedious').Connection; var Request = require('tedious').Request; var Types = require('tedious').Types; var config = {userName: '********', password: '********',server: 'localhost'}; var connection = new Connection(config); //Global var connectedclients = 0; var candidatedatenew = "NULL"; var candidatedateold = "NULL"; //Serve Page app.get('/', function(req, res){ res.sendFile(__dirname + '/Socket.html'); }); //HTTP Server Listen http.listen(3532, function(){ console.log('HTTP Server Listening On Port 3532'); }); //Socket Send And Receive io.on('connection', function(socket){ connectedclients++; console.log(connectedclients); socket.on('disconnect', function(){ connectedclients--; console.log(connectedclients); }); socket.on('chat message', function(msg){ console.log('message: ' + msg); io.emit('chat message'); }); }); //On MSSQL Server Connect connection.on('connect', function(err) { console.log("Connected To MSSQL"); executeStatement(); }); //SQL Query function executeStatement() { request = new Request("SELECT MAX([datetime]) [datetime] FROM [******].[**].[********];", function(err) { if (err) { console.log(err);} }); request.on('row', function(columns) { columns.forEach(function(column) { if (column.value === null) { candidatedatenew = "NULL"; } else { candidatedatenew = column.value; } }); }); connection.execSql(request); } //Refresh Query function sqlRefresh () { executeStatement(); if (candidatedatenew !== candidatedateold) { console.log(candidatedatenew); console.log(candidatedateold); io.emit('refresh'); candidatedateold = candidatedatenew; } } setInterval(sqlRefresh, 10000);

El problema es que mi código bajo sqlRefresh en la instrucción if parece activarse independientemente de si los valores son iguales o diferentes.

Probablemente sea algo realmente simple pero, como dije, soy un completo novato en esto.

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!