|
-
Feb 12th, 2004, 07:47 PM
#1
Thread Starter
Lively Member
Query Trouble
Hi, when I call rs.open I get the error: Too few parameters, Expected 1.
VB Code:
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim sql As String
Dim cboText As String
Set cn = New ADODB.Connection
cn.ConnectionString = "Driver={Microsoft Access Driver (*.mdb)};" & _
"Dbq=h:\project\db1.mdb;" & _
"Uid=admin;" & _
"Pwd="
cn.Open
Set rs = New ADODB.Recordset
cboText = cboClass.Text
sql = "SELECT StudentName FROM tblStudents WHERE " & _
"StudentClass1 = " & Quotes(cboText) & " OR " & _
"StudentClass2 = " & Quotes(cboText) & " OR " & _
"StudentClass3 = " & Quotes(cboText) & " OR " & _
"StudentClass4 = " & Quotes(cboText) & " OR " & _
"StudentClass5 = " & Quotes(cboText) & " OR " & _
"StudentClass6 = " & Quotes(cboText) & " OR " & _
"StudentClass7 = " & Quotes(cboText) & " OR " & _
"StudentClass8 = " & Quotes(cboText) & " OR " & _
"StudentClass9 = " & Quotes(cboText) & " OR " & _
"StudentClass10 = " & Quotes(cboText)
MsgBox sql
rs.Open sql, cn2
rs.MoveFirst
Do While Not rs.EOF
Any ideas?
Last edited by ironhide; Feb 12th, 2004 at 08:07 PM.
-
Feb 13th, 2004, 11:28 AM
#2
The usuall culprits for this error -
One of the database field names is misspelled.
Character data is not surrounded with single quotes.
VB Code:
"StudentClass1 = '" & Quotes(cboText) & "' OR " & _
-
Feb 13th, 2004, 02:18 PM
#3
Fanatic Member
Originally posted by brucevde
The usuall culprits for this error -
One of the database field names is misspelled.
Character data is not surrounded with single quotes.
VB Code:
"StudentClass1 = '" & Quotes(cboText) & "' OR " & _
since he's using access, doesn't he need to use double quotes??
simplest thing to do is debug.print sql and post it.
or you may find the problem.
It Never Fails. Everytime I try to make a program idiot proof, the world makes a better idiot.
-
Feb 13th, 2004, 03:08 PM
#4
since he's using access, doesn't he need to use double quotes??
Nope.
-
Feb 15th, 2004, 04:58 PM
#5
Thread Starter
Lively Member
The sql is statement is (using debug.print)
SELECT StudentName FROM tblStudents WHERE StudentClass1 = "12SDD" OR StudentClass2 = "12SDD" OR StudentClass3 = "12SDD" OR StudentClass4 = "12SDD" OR StudentClass5 = "12SDD" OR StudentClass6 = "12SDD" OR StudentClass7 = "12SDD" OR StudentClass8 = "12SDD" OR StudentClass9 = "12SDD" OR StudentClass10 = "12SDD"
When calling rs.open still gives me the too FEW ?? parameters, expected one...
Any help?
Ta.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|