[英]How do i insert a date from c#?
I have this insert:我有这个插入:
insert into sap_paghe (nome_elaborazione, data_elaborazione, tipo, data_registrazione, data_scadenza, data_documento, osservazioni, data_allocazione_iva) values ('Nome elaborazione', '2021-12-22', 'H', '2021-01-31', '2021-01-31', '2021-01-31', 'RETRIBUZIONI GEN. 2021', '2021-01-31');
which perfectly works from SQLWorkbench but gives this error using C#可以在 SQLWorkbench 上完美运行,但使用 C# 会出现此错误
ERROR [HY000] [Informix][Informix ODBC Driver][Informix]Invalid year in date
I'm 100% sure the connection works because other inserts work fine, it's just the ones with the date.我 100% 确定连接工作正常,因为其他插入工作正常,它只是带有日期的插入。 Any suggestion?
有什么建议吗?
Here's the code:这是代码:
OdbcCommand command = new OdbcCommand(insert..., DbConnection);
dataAdapter.InsertCommand = command;
dataAdapter.InsertCommand.ExecuteNonQuery();
command.Dispose();
Turns out i just needed to put TO_DATE('2021-01-31','%Y-%m-%d')
instead of just the date原来我只需要放
TO_DATE('2021-01-31','%Y-%m-%d')
而不仅仅是日期
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.