PDA

View Full Version : Db results in an array....possible?



Mojeaux
05-12-2006, 12:15 AM
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!:)

djr33
05-12-2006, 01:18 AM
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 :)

lihang
05-16-2006, 04:55 AM
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...