How to parameterize an in() statement in a table adapter RRS feed

  • Question

  • User-702198084 posted

    I'm trying to plug in a list of values for a field (using thetableadapter query configuartion wizard) , but the following doesn't work...


    Select a,b,c

    from tablename

    where (OrgID in(@OrgList))


    [OrgID is smallint, and @OrgList is string]


    I want the ultimate select command to be

    Select a,b,c

    from tablename

    where(OrgID in(1,2,3))


    When I set the parameter to  1,2,3  the wizard/execute complains that @OrgList is not smallint???

    If I change to cast(OrgID,vchar(10)  in(@OrgList))


     it compiles, but yields 0 records, unless I enter just one of the values (e.g. 1) as the parameter


    so... is there any way to parameterize an in() statement like this using the the wizard?? or should I just build the where clause myself, and add it on to the select statement?


    Thanks in advance...



    Monday, April 4, 2011 6:31 PM