怎么写sql更新语句?

mark2003 2003-12-23 12:11:06
我使用access数据库,有一个TimeClk表,其中IOTime字段是日期格式,他的数据格式为:2003-12-4 17:30:24,当我运行以下语句的时候总是出错,但如果我把条件IOTime=#"+listWorkTime->tempDate+"# ,去掉的话则能够正常运行,请问我的更新语句格式哪里错了?

错误信息为:不正常定义参数对象.提供了不一致或不完整信息

ADOQuery1->SQL->Add("update TimeClk set IOTime='"+tempDate+"',specialMemo='"+specialMemo+"' where IOTime=#"+listWorkTime->tempDate+"# and CompnyID='"+listWorkTime->compnyID+"'");

...全文
25 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
Chimae 2003-12-25
  • 打赏
  • 举报
回复
strSQL="update TimeClk set IOTime='"+tempDate+"', specialMemo='"+specialMemo+"' where IOTime='"+listWorkTime->tempDate+"' and CompnyID='"+listWorkTime->compnyID+"'"
IOTime='"+FormatDateTime("YYYY-MM-DD HH:MM:SS", listWorkTime->tempDate)+"'
Chimae 2003-12-24
  • 打赏
  • 举报
回复
listWorkTime->tempDate
你这个List中存放的是什么类型,String?还是TDateTime?
Chimae 2003-12-24
  • 打赏
  • 举报
回复
IOTime='"+FormatDateTime("YYYY-MM-DD HH:MM:SS", StrToDateTime(listWorkTime->tempDate))+"'
Chimae 2003-12-24
  • 打赏
  • 举报
回复
strSQL="update TimeClk set IOTime='"+tempDate+"', specialMemo='"+specialMemo+"' where IOTime='"+listWorkTime->tempDate+"' and CompnyID='"+listWorkTime->compnyID+"'"
IOTime字段是什么类型?日期的话,可以这样:
IOTime='"+FormatDateTime("YYYY-MM-DD", DateTimePicker1->Date)+"'
IOTime='"+FormatDateTime("YYYY-MM-DD", StrToDate(listWorkTime->tempDate))+"'
「已注销」 2003-12-24
  • 打赏
  • 举报
回复
update set
mark2003 2003-12-24
  • 打赏
  • 举报
回复
回复人: Chimae(齐藤) ( ) 信誉:99 2003-12-24 10:48:00 得分:0

listWorkTime->tempDate
你这个List中存放的是什么类型,String?还是TDateTime?

是TDateTime 类型


我不懂电脑 2003-12-24
  • 打赏
  • 举报
回复
把日期转换为字符串
mark2003 2003-12-24
  • 打赏
  • 举报
回复
还是不行,怎么回事,烦死我了
nobill 2003-12-23
  • 打赏
  • 举报
回复
TDateTime IOTime;
nobill 2003-12-23
  • 打赏
  • 举报
回复
ADOQuery1->SQL->Add("update TimeClk set IOTime='"+tempDate+"',specialMemo='"+specialMemo+"' where IOTime=:IOTime and CompnyID='"+listWorkTime->compnyID+"'");

ADOQuery1->Params->Items[0]->AsDateTime=IOTime ;


huoniao1976 2003-12-23
  • 打赏
  • 举报
回复
用'"+DateToStr(listWorkTime->tempDate)+"'"试试

13,826

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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