简体   繁体   English

SQL Server CE查询中的DateTime?

[英]DateTime in SQL Server CE query?

I have a date and time I'd like to insert into a SQL Server CE database, I'm trying to follow the string format yyyy-MM-dd hh:mm:ss but I get an invalid token exception when I try to insert it. 我有一个日期和时间我想插入一个SQL Server CE数据库,我正在尝试遵循字符串格式yyyy-MM-dd hh:mm:ss但是当我尝试插入时,我得到一个无效的令牌异常它。

If the format is just dd-MM-yyyy everything is fine but I need to be able to add the time of day too... 如果格式只是dd-MM-yyyy一切都很好但我需要能够添加时间...

始终最好使用参数:

cmd.Parameters.Add("@newTimeStamp", SqlDbType.DateTime).Value = timeStamp;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM