sql server - SQL insert posted in wrong row order -


i using node.js , mssql post values embedded device sql database. each interval increment row id , sensor value , "insert" database. however, when view database rows appear have been posted in wrong order (see screenshot). of missing entries appear later.

i have debugged code , events taking place in correct order. happening somewhere in transaction.

the code here:

var sql = require('mssql');     //sql   var = 0;  //database configuration var config = {    user: '*****',    password: '******',    server: '******',     database: '*******',     options: {       encrypt: false // use if you're on windows azure    } }  //main activity function called every 1 second periodicactivity();  //setinterval function sets period , function called setinterval(function () { periodicactivity() }, 1000)  // function periodicactivity() {         = + 1;     var y = math.random();      var connection = new sql.connection(config, function (err) {         // ... error checks         // query               var request = new sql.request(connection);         request.query('insert sensordata (id, data) values (' + + ',' + y + ')', function (err, recordset) {         // ... error checks     });  });  //close sql connection //connection.close(); } 

the database screenshot:

screenshot

any or suggestions welcome. thanks, t

the insertion done expect. data displayed in pseudorandom order caused internal thing. order data when selecting , done.

also, why not making id auto-incrementing primary key , make

request.query('insert sensordata (data) values (' + y + ')', function (err, recordset) {     // ... error checks }); 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -