vb.net 不允许从数据类型 datetime 到 int 的隐式转换错误。使用 CONVERT 函数运行此查询

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14873575/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 12:20:33  来源:igfitidea点击:

Error of Implicit conversion from data type datetime to int is not allowed. Use the CONVERT function to run this query

c#sqlsql-servervb.netsql-server-2005

提问by Jay Tankariya

I have table of stock with DOCDate field and it has datatype as datetime, when i am running my query, it shows me error

我有带有 DOCDate 字段的库存表,它的数据类型为日期时间,当我运行查询时,它显示错误

'Implicit conversion from data type datetime to int is not allowed. Use the CONVERT function to run this query.'

'不允许从数据类型 datetime 到 int 的隐式转换。使用 CONVERT 函数运行此查询。

My query is

我的查询是

insert into SSPERPStock (LinkID, DocNo, DocDate, VoucherType, ProductID, Weight, AL, InEdit, CreatedU??serId) 
values (IDENT_CURRENT('SSPERPDailyInkConsumptionTransaction'),'DOC1001','2013-02-??14','ICPacked',8,5,'L',0,GETDATE())

What can be the solution of this mistry??

这个迷雾的解决办法是什么??

回答by juergen d

You are trying to add a date (GETDATE()) to your column CreatedU??serId

您正在尝试将日期 ( GETDATE())添加到您的列CreatedU??serId

insert into SSPERPStock (... , CreatedU??serId) 
values (... , GETDATE())

which is probably an intand not what you wanted to do in the first place.

这可能int是您最初想做的,而不是您想做的。