Connecting Tech Pros Worldwide Help | Site Map

Multi Parameter Query - problem sending more then one parameter

Newbie
 
Join Date: Jul 2007
Posts: 2
#1: Jul 16 '07
Hi,

I am trying to create an ASP file which will search Multiple Values in a Database. Everything is fine if there is one parameter but if there are more I receive an SQL error message:

Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'Alt LIKE Pa_RaM000 OR WHERE Alt LIKE Pa_RaM001'.


Any help solving the problem would be appreciated (I am struggeling with it for almost 2 weeks and haven't managed to solve it).

the parameters come as a splited string (already splitted)

I am using the following code for parameter and query definition:
Expand|Select|Wrap|Line Numbers
  1. QString="SELECT PartNo, Alt, UNIT, QTY1 FROM Stock WHERE Alt LIKE ? "
  2.  
  3. for i=Lbound(Splitted) to Ubound(Splitted)
  4.    Recordset2__MMColParam=Splitted(i)
  5.    Recordset2_cmd.Prepared = true
  6.    set Param =  Recordset2_cmd.CreateParameter("param"+chr(i), 200, 1, 255, "%" + Recordset2__MMColParam + "%") ' adVarChar
  7.    Recordset2_cmd.Parameters.Append(Param)
  8.    if i>0 then 
  9.       QString = QString & "OR WHERE Alt LIKE ? "
  10.    end if
  11. next 
  12.  
  13. QString = QString & "ORDER BY Alt ASC" 
  14. Recordset2_cmd.CommandText=QString 
  15.  
Thanks,
Vesper Ventura
jhardman's Avatar
Moderator
 
Join Date: Jan 2007
Location: logan, utah
Posts: 2,690
#2: Jul 16 '07

re: Multi Parameter Query - problem sending more then one parameter


Vesper

Syntax should be "WHERE xxx LIKE 'Joe' OR xxx LIKE 'Fred' "...etc.
You should not say OR WHERE

Jared
Newbie
 
Join Date: Jul 2007
Posts: 2
#3: Jul 18 '07

re: Multi Parameter Query - problem sending more then one parameter


Quote:

Originally Posted by jhardman

Vesper

Syntax should be "WHERE xxx LIKE 'Joe' OR xxx LIKE 'Fred' "...etc.
You should not say OR WHERE

Jared


Thanks, I will try that right away.

Vesper Ventura
Reply