[ODBC Microsoft Access Driver] Too few parameters. Expected 2

Hello,

I keep getting this error message:

Microsoft OLE DB Provider for ODBC Drivers error ‘80040e10’
[ODBC Microsoft Access Driver] Too few parameters. Expected 2.
/jby2202/mz_asp_sql.asp, line 51

I’ve already checked line 51. It goes like this:

rsGlobalWeb.Open SqlJunk, dbGlobalWeb, 3, 3

As I can see, I already have 2 parameters. What error is the server refering to?

It is the statement in SqlJunk that is erroneous. A common cause is that you refer to non-existing columns or tables.

I’ve checked it already. and I don’t think I’m refering to any non-existing columns or tables.

hmm… my database has 6 columns. The 1st column is the “Auto-number” thingy. The other 5 contain the data which I have entered. When I run the search thing for the last 4 ‘headings’ or columns, I can get some results. But when I try to key in some numbers to search under the 2nd criteria, I get the error that I have too few parameters. Expected 2.

err… do you need to see the source code?

no, please, no source code

just the sql

DSNName = “DRIVER=Microsoft Access Driver (*.mdb);DBQ=”
DSNName = DSNName & Server.MapPath(“db1.mdb”)

Set dbGlobalWeb = Server.CreateObject(“ADODB.Connection”)
dbGlobalWeb.Open DSNName

SqlJunk = “SELECT * FROM [X/X_database]”

If Request.Form(“TypeSearch”) = “X/X” Then
SqlJunk = SqlJunk & " WHERE X/X LIKE ‘%" & _
Request.Form(“DaInBox”) & "%’"
End If

If Request.Form(“TypeSearch”) = “AN” Then
SqlJunk = SqlJunk & " WHERE AN LIKE ‘%" & _
Request.Form(“DaInBox”) & "%’"
End If

Set rsGlobalWeb = Server.CreateObject(“ADODB.Recordset”)
rsGlobalWeb.Open SqlJunk, dbGlobalWeb, 3, 3 ------> error occurred at this line

no, please, no source code

just display the sql statement after all the substitution of variables and stuff

err…I’m very sorry, i have no idea what you are saying. coz i’m like new to sql and stuff.

what statement after all the substitution of variables? er… can you give me an example?

hmm… ok do you mean this statement?

SqlJunk = “SELECT * FROM [X/X_database]”

yeah, that statement plus the WHERE clause

instead of executing the line that results in the error, just display the contents of the SqlJunk variable

my sql ststement does not have a WHERE clause because i need to use the entire database.
how am i supposed to display the contents of the SqlJunk variable?


Set rsGlobalWeb = Server.CreateObject("ADODB.Recordset")
response.write "Debug:" & SqlJunk
response.end
'rsGlobalWeb.Open SqlJunk, dbGlobalWeb, 3, 3 ------> error occurred at this line

if you have a column named X/X you must do


If Request.Form("TypeSearch") = "X/X" Then
SqlJunk = SqlJunk & " WHERE [X/X] LIKE '%" & _
Request.Form("DaInBox") & "%'"
End If

Better still, don’t use special characters in identifiers at all.