参数太少错误的MS Access SQL [英] Too few parameters error MS Access SQL
问题描述
我得到一个运行时错误:太少参数:预计2
I'm getting a run-time error: too few parameters: expected 2.
这code应该在排队的下一个员工的任务。员工 [程序]
和 [语言]
有相匹配的 [程序]
和 [语言]
表中的CFRRR。
This code is supposed to get the next employee in line for assignments. The employees [programs]
and [Language]
have to match the [program]
and [language]
in the table CFRRR.
strSQL = "SELECT TOP 1 WorkerID FROM attendance WHERE [Programs] LIKE '*" & program & "*' AND [Language] = '" & Language & "' AND [Status] = " & ("Available") & " ORDER BY TS ASC"
Set rs = db.OpenRecordset(strSQL, dbOpenDynaset)
下面就是 Debug.Print STRSQL
显示我:
SELECT TOP 1 WorkerID从考勤WHERE [程序] LIKE'*程序*'和[语言] LIKE'*语言*'和[状态] = BY TS ASC可用的顺序
推荐答案
假设你想要 [状态]
来匹配单词可用的,加报价马克<一个href="http://stackoverflow.com/questions/30142827/too-few-parameters-error-ms-access-sql/30142995#comment48394301_30142827">suggested ......
Assuming you want [Status]
to match the word Available, add quotes as Mark suggested ...
SELECT TOP 1 WorkerID FROM attendance
WHERE [Programs] LIKE '*program*' AND [Language] LIKE '*Language*' AND [Status] = 'Available'
ORDER BY TS ASC
但仍然离开一个参数下落不明。创建在Access查询设计一个新的查询。切换到SQL视图并在声明中粘贴文本。
However that still leaves one "parameter" unaccounted for. Create a new query in the Access query designer. Switch to SQL View and paste in your statement text.
当您尝试运行查询,存取会弹出一个输入对话框,要求您提供值的参数。该对话框中还包括访问已经被认为是该参数的话。
When you try to run that query, Access will pop up an input dialog asking you to supply a value for the parameter. That dialog also includes the word which Access assumes to be the parameter.
你的SQL语句进行比较的话。它通常是一个拼错对象(场或表)的名称,功能,或SQL关键字。在这种情况下,我不能当场功能或关键字的错误,所以会想这个问题是一个字段或表名。
Compare that word with your SQL statement. It is generally a misspelled object (field or table) name, function, or SQL keyword. In this case, I can't spot function or keyword errors, so will guess the problem is a field or table name.
这篇关于参数太少错误的MS Access SQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!