请帮忙:简单的SQL语句出错 [英] Please help: Error with simple SQL statement
问题描述
您好。我正在构建一个从组合框中检索值的进程,并根据该值,发生两个SQL进程之一。如果框中的值是-ALL-,则该值为-ALL-。然后选择表中的所有记录进行输出。如果输入的特定值不是-ALL-,则会发生单独的过程(表中与该值匹配的记录存储为DIVISION)。
这是我有的代码片段,我得到错误消息
"运行时错误3141 - SELECT语句包括拼写错误或缺失的保留字或参数名称,或者标点符号不正确
而且,是的 - 变量strSQL被声明...
任何人都可以看看这段代码并告诉我是什么我在使用Syntax或使用错误?在此先感谢。
Hi. I am building a process that retrieves a value from a combo box, and based on the value, one of two SQL processes occur. If the value from the box is "-ALL-" then all records from a table are selcted for output. If a specific value is entered that is NOT "-ALL-", a separate process occurs (records from the table that match the value are stored as DIVISION).
This is the piece of code i have in place, and I kep getting the error message
"Run Time error 3141 - The SELECT statement includes a reserved word or an argument name that is misspelled or missing, or the punctuation is incorrect"
And, yes - the variable strSQL is declared...
Can anyone look at this code and tell me what I am doing wrong with Syntax or use? Thanks in advance.
推荐答案
嗨。我正在构建一个从组合框中检索值的进程,并根据该值,发生两个SQL进程之一。如果框中的值是-ALL-,则该值为-ALL-。然后选择表中的所有记录进行输出。如果输入的特定值不是-ALL-,则会发生单独的过程(表中与该值匹配的记录存储为DIVISION)。
这是我有的代码片段,我得到错误消息
"运行时错误3141 - SELECT语句包括拼写错误或缺失的保留字或参数名称,或者标点符号不正确
而且,是的 - 变量strSQL被声明...
任何人都可以看看这段代码并告诉我是什么我在使用Syntax或使用错误?在此先感谢。
Hi. I am building a process that retrieves a value from a combo box, and based on the value, one of two SQL processes occur. If the value from the box is "-ALL-" then all records from a table are selcted for output. If a specific value is entered that is NOT "-ALL-", a separate process occurs (records from the table that match the value are stored as DIVISION).
This is the piece of code i have in place, and I kep getting the error message
"Run Time error 3141 - The SELECT statement includes a reserved word or an argument name that is misspelled or missing, or the punctuation is incorrect"
And, yes - the variable strSQL is declared...
Can anyone look at this code and tell me what I am doing wrong with Syntax or use? Thanks in advance.
请使用Code标签下次。
有2个问题。
1)你不能为*分配别名。这样做的意思是为每个字段命名相同的名称。
2)Div_Name似乎是一个文本值,在这种情况下你必须用strDiv包围单引号。 ie
Please use Code tags next time.
There are 2 problems.
1) You can''t assign an alias to *. What it would mean to do so is to name every field the same name.
2) Div_Name seems to be a text value in which case you''ll have to surround the strDiv with single quotes. i.e.
发布整个代码。
这篇关于请帮忙:简单的SQL语句出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!