How can I use a multiselect listbox to pass parameter to a SQL SP

J

Jeff Thur

I have a program where the user does database lookups. I
need to have a listbox where thue user can select one or
more states and a regular textbox to select a last name.
I am not sure how I can do this. I figure that the
programmer must build the criteria from the listbox
itself. Any ideas on how to pass the multiple selections
to a SQL Stored Procedure. The Textbox part is no
problem. Thanks for any help.
 
R

Riki

Jeff said:
I have a program where the user does database lookups. I
need to have a listbox where thue user can select one or
more states and a regular textbox to select a last name.
I am not sure how I can do this. I figure that the
programmer must build the criteria from the listbox
itself. Any ideas on how to pass the multiple selections
to a SQL Stored Procedure. The Textbox part is no
problem. Thanks for any help.

First concatenate the values into a string, separated by commas.
Pass this string to your sproc.

Then, in your SQL command, use the IN operator like this:
.... WHERE myField IN (@values) ...
 
K

Kostadin Kostov

Use dataset, and DataAdapter that populates the changes in your dataset to
the database using your stored procedure.

Hope that helps!
Regards,
Kostadin Kostov
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,015
Latest member
AmbrosePal

Latest Threads

Top