If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > select query based on the selection made on the listbox

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-23-04, 15:42
nubee nubee is offline
Registered User
 
Join Date: Oct 2004
Posts: 10
select query based on the selection made on the listbox

I have a Multiple Select listbox with values for eg: a, b, c, d, e etc. If I select a,b,c from the listbox, I should be able to make a select query based on that. Like this: select a,b,c from table.

what should I do to collect the values from the listbox and reproduce them to the select query?

I am able to collect the values using a for loop and I am not sure whether to add that in a vector or something to reproduce in the select query.

Code I have wriiten so far:
Mcol_lst is the name of the listbox.
String[] sele = request.getParameterValues("Mcol_lst");
if(sele !=null) {
for(int i=0;i<sele.length;i++) {
System.out.println("dffdsfsdf"+i);
vec.add(params[i]);
}
}

rs=st.executeQuery("Select ["+request.getParameterValues("Mcol_lst")+"] from [Base Inventory Table]);

There should be a "comma" after each item selected to do the select query, how should I get that?

I am using JSP and Beans but I guess I can manipulate ASP/vb script code provided by you in the way I want.

Please help,
Thanks
Reply With Quote
  #2 (permalink)  
Old 11-23-04, 22:02
RedAxl RedAxl is offline
Registered User
 
Join Date: Nov 2004
Posts: 39
SELECT statement DONT return same fields in LINE format.
SELECT Statements ALWAYS returns same fields in a column format,
UNLESS you create Stored Procedure for that.

In querying the selected items in lists,
You can construct your WHERE clause while LOOPing to that list and
checks if the current item is selected. If item is selected, Add it to your
filter using OR statement.
Reply With Quote
  #3 (permalink)  
Old 12-02-04, 12:00
nubee nubee is offline
Registered User
 
Join Date: Oct 2004
Posts: 10
Thank You very much for the reply.
Sorry it took me so long to respond. I was on vacation so I couldnot check my mails.

I am using Access database. javaBeans and JSP. Does MS Access support Stored procedures. If yes could you please post a code snippet?

I have a Multiple Select listbox with values for eg: a, b, c, d, e etc. If I
> select a,b,c from the listbox, I should be able to make a select query based
> on that. Like this: select a,b,c from table.
>
> what should I do to collect the values from the listbox and reproduce them
> to the select query?
>
> I am able to collect the values using a for loop and I am not sure whether
> to add that in a vector or something else to reproduce in the select query.

Thanks,
Nubee
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On