参数语法错误 [英] Parameter syntax error

查看:90
本文介绍了参数语法错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我在查找SQL字符串时遇到了麻烦。我在参数子句中收到?语法错误?


我认为我没有超过SQL字符串的字符数。


还确保参数行后面的分号并插入?& _?在我的VBA代码的每一端。


所有参数都是文本。当我在没有参数的Access''查询工具中尝试时,查询运行。


你看到我哪里出错了吗?


谢谢。

展开 | 选择 | Wrap | 行号

解决方案

在开头取出参数。如果您试图引用表单上的控件,则不需要它。


您好Qtip,


关注我与参数本身有关。你要做的是使用PARAMETERS子句将表单中的文本框值直接传递给查询,我不认为这样可行。您需要调用其他参数,然后使用QueryDef对象的Parameters集合为每个参数执行显式赋值:

展开 | 选择 | Wrap | 行号

Per Rabbit的建议,如果你删除了PARAMETERS子句,你可以像你想要的那样使用WHERE子句中的控制值,但你不能将它们包含在SQL字符串中;它们必须与字符串连接。例如:

展开 | 选择 | Wrap | 行号


Hello all,

I am at a lost with troubleshooting my SQL string. I am receiving a ?Syntax error in parameter clause?.

I do not think I have exceeded the number of characters for a SQL string.

Also ensured the semicolon after the Parameters line and inserted with ?& _? on each end within my VBA code.

All parameters are text. When I tried in Access'' Query tool without parameters, the query runs.

Do you see where I went wrong?

Thanks.

Expand|Select|Wrap|Line Numbers

解决方案

Take out the parameter stuff at the beginning. If you''re trying to reference a control on a form, you don''t need it.


Hi Qtip,

The concern I have has to do with the parameters themselves. What you''re trying to do is pass text box values from your form directly into the query using the PARAMETERS clause, and I don''t think that can work. You would need to call the parameters something else and then do an explicit assignment for each one using the Parameters collection of your QueryDef object:

Expand|Select|Wrap|Line Numbers


Per Rabbit''s suggestion, if you remove the PARAMETERS clause you can use the control values in the WHERE clause as you are trying to do, but you cannot include them inside the SQL string; they must be concatenated with the string. For example:

Expand|Select|Wrap|Line Numbers


这篇关于参数语法错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆