Parameterized queries with where clause including 'in'



I've searched for a while now to see an example of using a
parameterized query using the 'in' keyword in a SELECT query and can't
find anything that works. I'm working with VBScript in an ASP page.

If I have a recordset opened with a query like this:
inClause = "'user1','user2','user3'"
"SELECT * FROM myTable where USERID IN (" + inClause + ")"

it works fine. However if I use an adodb command object because I would
like to use parameterized queries and I do the following

sqlStr = "SELECT * FROM myTable where USERID IN (?)"
cmd.CommandText=sqlStr

set param1=cmd.CreateParameter("USERID",200,1,255,inClause)
cmd.Parameters.Append param1
set rs = cmd.Execute

the recordset always comes back with BOF and EOF true. No records are
returned. Anybody out there have a clue what I'm doing wrong? I've been
banging my head against this for a while. Any help would be greatly
appreciated.

Thanks.

Mike

.



Relevant Pages

  • Re: escape the and " chars to insert them onto an Access database
    ... using a parameterized query, and then just set the value of the parameter to ... Syntax error in query expression ... Object& executeResult)> at System.Data.OleDb.OleDbCommand.ExecuteCommandText ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: How to fill dataset with just one row at a time?
    ... If you use a stored proc or a parameterized query, ... parameter to the SelectCommand. ... If you do not know the primary keys in which to query for a single item at a ... Can any one adivse? ...
    (microsoft.public.dotnet.academic)
  • Re: Parameterized queries with where clause including in
    ... > parameterized query using the 'in' keyword in a SELECT query and can't ... > the recordset always comes back with BOF and EOF true. ... USERID that matches the entire string, ...
    (microsoft.public.data.ado)
  • Re: Aggregates on DateTime fields
    ... In a simple parameterized query ... >In code set the parameter and open, the TField returned is not null, but has ... Now link a data aware control to this query, ... >and without a linked control. ...
    (borland.public.delphi.database.ado)
  • Parameterized Query No rows effected
    ... I have a parameterized query of the following form ... All parameters are ftInteger, input direction, set to integer values before ... Executed within a transaction after another query that updates ... non-parameterized query building the SQL text dymanically. ...
    (borland.public.delphi.database.ado)