Link to home
Start Free TrialLog in
Avatar of Murray Brown
Murray BrownFlag for United Kingdom of Great Britain and Northern Ireland

asked on

ASP.net Table Adapter SQL LIKE STATEMENT - unknown number criteria

Hi

I have a table adapter in ASP.net 4 that uses the code in the code selection below.
The number of parameters passed in can vary between 2 and 20 so how do I set up
a SQL statement to handle varying numbers of parameters (not just 2 as shown below)
SELECT        colDate, colTime, colDetail
FROM            Table1
WHERE        (colDetail LIKE @Parameter1 + '%') OR
                         (colDetail LIKE @Parameter2 + '%')

Open in new window

Avatar of Sharath S
Sharath S
Flag of United States of America image

You need dynamic sql. How are you getting the parameters?
ASKER CERTIFIED SOLUTION
Avatar of Manoj Patil
Manoj Patil
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
To get ParameterCount you can create an array of user input and check the count.
Avatar of Murray Brown

ASKER

Hi. How would I create that array. Thanks
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
When user add input or for example if he compare products , when he click on product, get the product ID and store it in array  
thanks very much