这是我的密码:
const result = await connection.query("INSERT INTO myTable ([ID],[ClassId],[Active],
[LastUpdateDateTime],[LastUpdateUser],[Number],[ExternalId],
[MaterialDefinitionId],[CompanyId],[IsBlanket],[Type],[Subtype],
[CreatedDate],[ValidFromDate],[ValidToDate],[OrderedQuantity],
[DeliveredQuantity],[ReservedQuantity],[UnitOfMeasurement],[Status],[Note])
VALUES (?,?,?,CONVERT(DATETIME, ? , 102),?,?,?,?,?,?,?,
?,CONVERT(DATETIME, ? , 102),CONVERT(DATETIME, ?, 102),
CONVERT(DATETIME, ? , 102),?,?,?,?,?,?)" ,
['100000061', 'Order' , 1,
'2020-01-01 11:11:11' , 'xxx' , 123 , '9901177998' , '100000003' ,
'100000012' , 0 , 'xxx', 'xxx', '2020-01-01 11:11:11' ,
'2020-01-01 11:11:11' , '2020-01-01 11:11:11' , 2000.0 ,
0.0 , 0.0, 'xxx' , 'Created' , 'xxx']);
正如您所看到的,我正在尝试插入时间,但出现了以下错误:“?”附近的requesterror:语法不正确。
有人知道解决办法吗?
谢谢!
1条答案
按热度按时间um6iljoc1#
您需要为中的参数使用数组
connection.query
函数来设置值。你可能只在你的案子里设置了第一个。支票:https://www.mysqltutorial.org/mysql-nodejs/insert/
应该是这样的:
在您的情况下,您应该尝试: