命令包含未识别的短语/关键字

发布于 2024-11-09 22:07:46 字数 469 浏览 3 评论 0原文

我有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

水中月 2024-11-16 22:07:46

试试这个:

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

看起来您在 WHERE 关键字之前缺少一个空格,并且在 emp_code 之后缺少一个单引号。您的交易日期似乎也有问题。

Try this:

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

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.

她比我温柔 2024-11-16 22:07:46

如果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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文