命令包含未识别的短语/关键字
我有一个 vb6 项目,我需要从记录集更新 Visual FoxPro 表。我的问题是,当我尝试更新表时,我收到错误消息:命令包含未识别的短语/关键字。我的问题位于涉及日期字段的位置。我不知道我是否正确编写了代码的最后部分。这是我的代码:
rs2.Open "update transac set no_ot_1_5 = " & rs1.Fields("ovt1") & ", no_ot_2_0 = " & rs1.Fields("ovt2") & ", no_ot_3_0" _
& "= " & rs1.Fields("ovt3") & "where code = '" & rs1.Fields("emp_code") & "and transac.date = & trans.txtend &", cn1, adOpenDynamic, adLockPessimistic
I have a vb6 project and i need to update a visual foxpro table from a recordset.My issue is when i try to update the table i get error msg:Command contains unregnized phrase/keywords.My problem is situated where the date field is concern.I dont know if i written the last portion of the code right.Here is my code:
rs2.Open "update transac set no_ot_1_5 = " & rs1.Fields("ovt1") & ", no_ot_2_0 = " & rs1.Fields("ovt2") & ", no_ot_3_0" _
& "= " & rs1.Fields("ovt3") & "where code = '" & rs1.Fields("emp_code") & "and transac.date = & trans.txtend &", cn1, adOpenDynamic, adLockPessimistic
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
试试这个:
看起来您在 WHERE 关键字之前缺少一个空格,并且在 emp_code 之后缺少一个单引号。您的交易日期似乎也有问题。
Try this:
It looks like you were missing a space before the WHERE keyword and you missed a single-quote after emp_code. It also looks like you had a problem with transac date.
如果G Mastros 的解决方案仍然不完整,则可能是由于“日期”字段的数据类型不正确。您可能需要更改为
transac.date = CTOD('" & trans.txtend &"') " ,
就像您发送文本字符串一样,但日期是 DATE 类型字段,您需要将其转换为 VFP 识别的函数... CTOD() 是将字符串转换为日期。
If the solution from G Mastros is still not complete, it may be due to incorrect data type of a "Date" field. you may need to change to
transac.date = CTOD('" & trans.txtend &"') "
as if you are sending in a text string, but the date is of a DATE type field, you'll need to have it converted to a VFP recognized function... CTOD() is Convert Character String to a Date.