Reciving String saved wrong in the database

I have an api using Express.js that recives data from Sigfox(A service for IoT) and … Read more Reciving String saved wrong in the database

I have an api using Express.js that recives data from Sigfox(A service for IoT) and inserts the data into the SQLServer Express database, this data comes in 4 different URL with this format:

http://servername:port/api/mediciones/sigfox_libelium/aire/2059E7/230934644ae17a8441/1626762070/9

My solution to insert all the data, is to create an Array and fill it with the parsed data from the all 4 URL.

    [
'2059E7',
 64,
 16.559999465942383,
 98.3505859375,
 100161.21875,
 1.7199997901916504,
 3.1599998474121094,
 16.219999313354492
]

When the last request comes and the array is filled, an Insert is made into the database table:

 .query("INSERT INTO medicionAire(fecha,id, bateria, temperatura, humedad, presionatmosferica, pm1, pm2, pm10) VALUES(SYSDATETIME()," + dimensiones[0] + ", "+ dimensiones[1] + ", " + dimensiones[2] + ", " + dimensiones[3] + ", " + dimensiones[4] + ", " + dimensiones[5] + ", " + dimensiones[6] + ", " + dimensiones[7] + ");")

where Dimensiones[] is the array filled with data.

ID should be "2059E7" like in the URL but when saved looks like this

enter image description here

Source: JavaSript – Stack Overflow



Leave a Reply

Your email address will not be published. Required fields are marked *