【问题标题】:TimeStamp , {"Failed to convert parameter value from a DateTime to a Byte[]."}TimeStamp , {"将参数值从 DateTime 转换为 Byte[] 失败。"}
【发布时间】:2014-06-02 08:04:59
【问题描述】:

得到错误

{"Failed to convert parameter value from a DateTime to a Byte[]."}

我尝试了时间戳,但得到了错误

cmd.Parameters.Add("@DATETIME", SqlDbType.Timestamp).Value = DateTime.Now;

【问题讨论】:

标签: c#


【解决方案1】:

如果要将 DateTime 分配给参数的值,请将其类型更改为 SqlDbType.DateTime。

【讨论】:

    【解决方案2】:

    Sql server 的时间戳不是日期/时间,因此不能将其转换为日期时间,反之亦然。

    看详细解释here

    改用日期时间。

    【讨论】:

      猜你喜欢
      • 2018-05-20
      • 2012-03-10
      • 2020-12-15
      • 2022-01-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-29
      • 2017-08-14
      相关资源
      最近更新 更多