Hey all
I have a vb.net/asp.net dynamic website connected to an access database using a oledb connection. I use a datareader to retrieve the results of a query and iterate through the results using the read() method.
The page in question is a string matching search page (its a photo site and the photos have associated tags) that may return multiple results. I wish to display the first picture match and its details and then have a button that can be clicked to go to the next match and so on. So I need to call the read method on the datareader in a separate button click to the one in which it is created. But the reference to the datareader seems to get garbage collected as soon as the original click method completes.
So I tried instead to use a while loop to call the read method to build an array full of the data I needed from the reader and then read the next index of the array each time the nextbutton_click method runs (which id track with a static variable or something). But I cannot work out how to access this array from a separate method. It cannot be passed in as a parameter because its a button click, and needs to be called at random not immediately after the search button is pressed. Ive also tried using a single method that both the search button and the next button call to build/access the array depending on the integer passed in (like a switch) but of course if the array and other variables are defined in this method then they gets reinitialised everytime its called (thanks to the compiler not allowing variables defined in an if statement to be called outside it)
in summary: if I build an array (or any variable) in one method and wish to access it in another but cannot pass it to this second method as a parameter and cant use global variables (or can I?), what do I do?
there must be a simple way of doing this in web applications
or is this simply a limitation of this type of programming?
thanks bcshaw