Mar 07, 2010 04:14 AM|KraGiE|LINK
Please do not by any means deploy to production anything that looks like Dim sql As String = "select..."
That will only lead to drama that you don't wish to experience. Make a stored procedure.
Using the IN keyword has it's benefits, but you're better off tuning a stored procedure to retrieve products based on the id in an exact form.
Here's the deal. You're going to tear up your database runtime memory by executing that query over and over again. You're also going to tear up your web servers GC by concatenating strings like that in a loop. This method will "work" or appear to work,
but it is definitely the ghetto fabulous duct tape method. It will fall apart.
If you want, you can make the parameter of the stored procedure be a comma delimited string, and have the procedure parse the string, and make a table variable to fill with the appropriate data, and return that.