Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Page scrolling in search results

Status
Not open for further replies.

tvbruwae

Programmer
Aug 9, 2001
224
EU
Hi

I created an Interdev ASP site with MS SQL server running behind it as a data source. From the SQL tables I want to display the entire contents when the index page is loaded, so I used the "Select * from Overview" command in the SQL recordset. When entering a string in a textbox, the database looks for any values that contain this string. Therefore, different buttons call the next procedure with different values for the s_ID parameter :

sub SetQuery(S_ID)
Dim S_String
S_String = S_box.value
if S_String <> &quot;&quot; then
SQLString = &quot;SELECT * FROM Overview WHERE &quot; + trim (S_ID) + &quot; LIKE &quot;
SQLString = SQLString + &quot;'&quot; + trim(S_String) + &quot;%'&quot;
else
SQLString = &quot;SELECT * FROM Overview&quot;
end if
Search.close()
Search.setSQLText(SQLString)
Search.open()
end sub

Until now, everything works fine : the grid that is linked to the recordset shows the entire DB contents when first loading the page and when no value is entered before a search, and it displays the search results when a valid search parameter is supplied.

However, when the scroll buttons at the bottom of the grid are pressed after a search (when for example the grid shows page 1 of 3 of the search results), the grid continues with page 2... of the entire table contents (so page 2 of 865 instead of the 3 pages with search results). Apparently, the recordset opens with the adapted SQL statement after a search, but when you start to scroll it seems to take the default SQL statement (Select * ...) back. Can these scroll buttons be redefined to use the search SQL command, or is there any other solution to solve this?

Thanks for helping.

Tim
 
Hi

I guess that pretty simple solution is that on your navigation links you simply send your s_ID and then on that page before you run sql check is request.querystring(&quot;s_ID&quot;)=&quot;&quot; if so then you will run sql which will return everything.
Basicly, this is only first time or if you do not enter anything in textbox and start search.
If s_ID<>&quot;&quot; then it will continue with it instead trying to pick up value from textbox which is empty by opening new page or calling same page again.

Hope that this will help you,
Oliver
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top