Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Paging Records

Author  Topic 

josethegeek
Starting Member

45 Posts

Posted - 2003-08-21 : 19:10:13
I'm currently working on an online community, and we have a feature that lets members search for other member. They will enter a set criteria(age, gender, etc) to limit the results they recieve.

I have a store procedure that returns the members who meet their criteria. So for example it would return 100 members, 10 per page, 10 pages. The problem I'm running into is, for example your on page 1 of page 10, you click on member #6. You will be take to the members profile page, I would like to have a "previous" and "next" button. What would be the most efficient way to do this. How would I figure out the next member who was on the list, that met their criteria.

It's exactly how the SQL team forum(Snitz) works. When you are in a topic you have a previous" and a "next " function that will take you to the set topic. It will not just page all the topics, but the topics that met your critera(date limit, etc).

Thank you.

rrb
SQLTeam Poet Laureate

1479 Posts

Posted - 2003-08-21 : 22:25:02
check out [url]http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=25496[/url]

and then [url]http://www.sqlteam.com/SearchResults.asp?SearchTerms=paging[/url] if that's no good.

--
I hope that when I die someone will say of me "That guy sure owed me a lot of money"
Go to Top of Page

josethegeek
Starting Member

45 Posts

Posted - 2003-08-26 : 18:03:37
quote:
Originally posted by rrb

check out [url]http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=25496[/url]

and then [url]http://www.sqlteam.com/SearchResults.asp?SearchTerms=paging[/url] if that's no good.

--
I hope that when I die someone will say of me "That guy sure owed me a lot of money"



Thank you. But I know how to do this. What I need to do is page 1 record at a time.
Go to Top of Page

rrb
SQLTeam Poet Laureate

1479 Posts

Posted - 2003-08-26 : 19:01:43
Well, OK, the most efficient way to do this will depend on how many records you have in total. If it's less than 5000 or so , I'd dump the whole lot into a table, generating row-number (identity(1,1) if they're sorted for the insert). Then you can re-use that table until it's updated, or until the next user wants it. The row number becomes the key for paging, you retrieve records "WHERE rownumber between 5 and 10" or (for a single record) "WHERE rownumber =3". The previous and next buttons just change the row number bounds you're after.

But tell me more - because what i've just suggested is ok if the records aren't changing all that often, and if the user is quite likely to want to go to the previous or next....

--
I hope that when I die someone will say of me "That guy sure owed me a lot of money"
Go to Top of Page

josethegeek
Starting Member

45 Posts

Posted - 2003-08-27 : 15:37:31
quote:
Originally posted by rrb

Well, OK, the most efficient way to do this will depend on how many records you have in total. If it's less than 5000 or so , I'd dump the whole lot into a table, generating row-number (identity(1,1) if they're sorted for the insert). Then you can re-use that table until it's updated, or until the next user wants it. The row number becomes the key for paging, you retrieve records "WHERE rownumber between 5 and 10" or (for a single record) "WHERE rownumber =3". The previous and next buttons just change the row number bounds you're after.

But tell me more - because what i've just suggested is ok if the records aren't changing all that often, and if the user is quite likely to want to go to the previous or next....

--
I hope that when I die someone will say of me "That guy sure owed me a lot of money"



Thank you. That is what I had in mind, but it seemed to resource intensive. I was just wondering if there was another way. Thanks.
Go to Top of Page
   

- Advertisement -