Windows Develop Bookmark and Share   
 index > Windows Forms General > Question using IN clause and parameters in oledb command
 

Question using IN clause and parameters in oledb command

Hi all,
II was wondering if anyone knew if I can do something like the following...

cmd.commandtext = 'SELECT id FROM tbl WHERE id IN (@listOfIntegers)'
cmd.parameters.add('@listOfIntegers', oledbtype.integer).value = "12, 14, 16"



I can't seem to get it working (if it can work?).
Firstly, the the numbers are integers but it is being submitted as a string so i realize that is an issue.

I have always built the query string up just by...


strQry = 'select id from tbl where id IN (' + listOfIntegers + ')'


Does anyone know how I can do this using parameters?

Thanks for your time.
MigrationUser 1  Thursday, June 02, 2005 3:38 AM
I don't think this is possible. If the number of integers in the list was constant, you could have a parameter for each and select WHERE id=@a OR id=@b OR ...

Otherwise, you could put the integers into a temporary table in the database and join both tables.
MigrationUser 1  Saturday, June 04, 2005 7:14 AM

You can use google to search for other answers

Custom Search

More Threads

• Software Patents ???
• WebBrowser embedded resources
• Precise positioning
• incorrect synatx near keyword where
• Child Window Doest Recieve Messages
• Access menustrip in different From
• Repositioning ToolStrip at runtime
• selectedtext changed event
• MDI List Property in Menu Strip in VS 2005
• Datagrid heirarchy