Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2004
    Posts
    10

    Unanswered: 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

  2. #2
    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.

  3. #3
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •