求助大佬,使用tedious连接SQL server数据库的问题
nodejs吧
全部回复
仅看楼主
level 2
zx575645128 楼主
代码如下:
2018年01月19日 07点01分 1
level 2
zx575645128 楼主
第一次连接没有问题,也能正确读取到数据,但是第二次执行的时候就会卡在执行sql之前的地方,求解是什么原因?
2018年01月19日 07点01分 2
level 2
zx575645128 楼主
是这问题太简单了么,都没人理我?
2018年01月22日 01点01分 3
level 5
直接就可以连接sqlserver啊,为啥用这个
2018年01月27日 16点01分 4
请问怎么直连?
2018年01月29日 08点01分
回复 zx575645128 :安装个mssql然后require,我现在只是console.log出来了,现在想构造出httpserver然后res出来,这步还没弄出来
2018年01月29日 08点01分
Mssql也不行
2018年01月29日 09点01分
回复 zx575645128 :能连,我不是都说了,我已经console.log出来了,现在准备把数据显示到网页上
2018年01月29日 09点01分
level 2
停留在哪一步?没实验代码?有报错吗?贴出来看看
2018年01月28日 12点01分 5
实验代码在楼下
2018年01月29日 08点01分
level 2
zx575645128 楼主
2018年01月29日 08点01分 6
level 2
zx575645128 楼主
2018年01月29日 09点01分 8
level 2
zx575645128 楼主
class postData {
_getDate(fc){
console.log('取称重数据 ID', lastId);
var sql = 'SELECT top 1 * FROM \u79f0\u91cd\u4fe1\u606f where \u5e8f\u53f7>' + lastId + ' order by \u5e8f\u53f7 ';
// console.log('SQL', sql);
db.querySql(sql).then(data=>{
//console.log(data)
fc(data);
}).catch(error => {
fc([]);
console.error(error );
});
}
_postDate(item,fc){
console.log(item['\u5e8f\u53f7'])
lastId=item['\u5e8f\u53f7']
var postData={};
postData['creator_id']=item['\u5e8f\u53f7'];
postData['weight_id']='code002';
postData['weight_code']='code002';
postData['weight_rfid']='0';
postData['veh_id']=item['\u6d41\u6c34\u53f7'];
postData['car_no']=item['\u8f66\u53f7'];
postData['weight_gross']=item['\u6bdb\u91cd'];
postData['weight_veh']=item['\u76ae\u91cd'];
postData['weight_net']=item['\u51c0\u91cd'];
postData['garbage_type']=item['\u8d27\u540d'];
postData['weight_date']=item['\u76ae\u91cd\u65f6\u95f4'];
postData['delivery_unit']=item['\u53d1\u8d27\u5355\u4f4d'];
postData['prj_id']=2;
postData['tcar_company_id']=0;
postData['creator_id']=item['\u5e8f\u53f7'];
// console.log('post data' , postData);
client.post('/jsonapi/cancu_weight/add.json',
postData, function (err, res, body) {
if (err){
console.error(err);
}
else{
console.log('post resp',body);
fc({code:0});
}
});
}
_time(fc){
var _self = this;
_self._getDate((r)=>{
var d=r||[];
if(d.length<=0){
fc({code:-1});
return;
}
_self._postDate(d,fc);
})
}
run(fc){
var _self = this;
_self._time(d=>{
setTimeout(function () {
_self.run();
},timeBw );
},timeBw)
}
}
var t= new postData();
t.run();
2018年01月29日 09点01分 9
1