Advanced Search

Results 1 to 3 of 3

Thread: Db results in an array....possible?

  1. #1
    Join Date
    May 2006
    Location
    Houston, Texas
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation Db results in an array....possible?

    Hi,
    Desparately need your assistance. Is it possible to return results from an access db in an array?

    I have a function that connects to Access97 and the select/query statement returns a list of values. I can 'response.write' them in html, but need them to be in a combo box.

    I was thinking of having the array populate the combo box, but I'm missing a step. How do I get the results into the array? Could I use a variable? If so, would I need to parse for each option?

    I know ASP/VBscript/etc... would be much easier, but these are not an option for me.

    Thank you!

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    11,787
    Thanks
    225
    Thanked 657 Times in 645 Posts

    Default

    Hmmm... i'm not sure how well writing a code with that same language works. I mean... you can't have a program program itself.

    So... shouldn't be that hard, though. (as long as you're not trying to add code to the script)
    What you should do is use for or while loops (does JS even have these? I use php, so can't promise it'll work).

    Use a while statement to set:
    array[n] = result;
    During that loop, make n get bigger each time and result be the next result... however that will work.

    Hopefully pointing you the right way
    Daniel - Freelance Web Design | <?php?> | <html>| Deutsch | italiano | español | português | català | un peu de français | Ninasoma Kiswahili | 日本語の学生でした。| درست العربية

  3. #3
    Join Date
    May 2006
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Maybe, you can try to use a loop to show all of the result, like this:

    String [] result = new String[]; //Of course,you can use other type, int etc.
    int i = 0;
    while(rs.next()){
    result[i] = rs.getString(1);
    i = i + 1;
    }

    Now, the resultset is in result[].

    Hope they are helpful...

Bookmarks

Posting Permissions

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