無法保存datatime值。

zzxap 2008-07-30 07:38:32
string LstTime = DateTime.Now.ToString();
string sql_add = "update I_ChgToolTime set ... LstTime='"+LstTime='"+Convert.ToDateTime(LstTime)+"'' where ... " ;
数据库字段LstTime为datetime(8)类型。
提示:Syntax error converting datetime from character string.



...全文
60 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
baihe_591 2008-07-31
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 zck98530 的回复:]
你是在ACCESS里执行,还是SQL2000里执行,
感觉你的SQL语句生成的有问题.
[/Quote]


Access 要用到'#2008-12-30#'
zck98530 2008-07-31
  • 打赏
  • 举报
回复
你是在ACCESS里执行,还是SQL2000里执行,
感觉你的SQL语句生成的有问题.
zzxap 2008-07-31
  • 打赏
  • 举报
回复
数据库字段LstTime为datetime(8)类型
zzxap 2008-07-31
  • 打赏
  • 举报
回复
LstTime='"+LstTime='"+LstTime+"'' where
這樣還是提示Syntax error converting datetime from character string.
wdgphc 2008-07-30
  • 打赏
  • 举报
回复
干吗要写那么多个LstTime

直接 string sql_add = "update I_ChgToolTime set ... LstTime='"+ LstTime +"' where ... " ;
zzxap 2008-07-30
  • 打赏
  • 举报
回复
LstTime='"+LstTime='"+LstTime+"'' where
這樣還是提示Syntax error converting datetime from character string.
wdgphc 2008-07-30
  • 打赏
  • 举报
回复
""配的不对. 你自己把LstTime赋个值,然后把sql_add 打印出来看看是不是sql语句?

是不是

string sql_add = "update I_ChgToolTime set ... LstTime='"+ LstTime +"' where ... " ;
我姓区不姓区 2008-07-30
  • 打赏
  • 举报
回复
干吗还要再转成DateTime,直接string sql_add = "update I_ChgToolTime set ... LstTime='"+LstTime='"+LstTime+"'' where ... " ; 就好了

110,536

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧