当前位置:Gxlcms > mysql > mysql-sprintf_s问题,求助

mysql-sprintf_s问题,求助

时间:2021-07-01 10:21:17 帮助过:60人阅读

mysqlvs2008sprintf_s

组装一条mysql语句:
sprintf_s(strSql, "INSERT INTO twifibox_runninglogs VALUES
(NULL,'%u', '%s', FROM_UNIXTIME('%u'), '%.1f', '%.1f', '%d', '%d', NULL)\r\n",
DeviceId, RoomID, time(NULL), (float)pTh->s16CurRoomTemp/10,
(float)pTh->s16TrgRoomTemp/10, pTh->u8WarmState, pTh->WorkMode);

日志打印:
INSERT INTO twifibox_runninglogs VALUES (NULL,'589923834', '232985fa',
FROM_UNIXTIME('1439538081'), '0.0', '0.0', '1077215232', '0', NULL)

FROM_UNIXTIME('%u') 后面的全部错误,调试跟踪了:
pTh->s16CurRoomTemp = 252
pTh->s16TrgRoomTemp = 350
pTh->u8WarmState = 0
pTh->WorkMode = 1

看了很多遍,没发现有不妥的地方,参数都对齐了,求帮助
time(NULL) 不能直接用,得先用临时值保存?或者%u的格式用错了?
但是其他地方同样的用法又没出错

人气教程排行