Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1497
  • Last Modified:

TableAdapter parameter with multiple values

I have a TableAdapter Query for which I would like to pass a parameter with multiple values.

The underlying query uses a " .... WHERE A in (@Values)......" type command.

Field "A" is of type int

I've changed the parameter type of the parameter to string to allow me to pass a value like "1,2,3"

However, when I execute the query, I get a "Conversion failed when converting the varchar value '1,2,3' to data type int" error.

ANY help / advice would be appreciated, even if I have to use other objects instead of the genereated TableAdapters.
0
benjvr
Asked:
benjvr
1 Solution
 
Aneesh RetnakaranDatabase AdministratorCommented:
you should use dynamic sql

exec (' select ............  where a in (' + @values +' )'   )
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now