Jump to content

Asp Paging?


Recommended Posts

Hello,I have a couple of questions here.I have a recordset which contains city, employee as the fields. How do I get the number of cities (distinct cities) in the recordset without having to use an sql statement again? Also, is there an easy way to implement paging in a classic asp page.I have everything set up but it does not work the way I need it to because the rowspan on my table depends on the number of employees per city. I was able to get the number of employees per city by filtering by city but the problem is that when I ues paging one of the employees may be on the previous page and so the rowspan messes up. This is getting REAAAALLLY confusing.How do I find the number of employees per city per that rs.PageSize?Is there an easier way to do implement paging? I've finished everything else that needs to be done it is just the paging which is getting really really complicated.

Link to post
Share on other sites

If you want to get all of the cities in a recordset you need to loop through the recordset and build a list of the cities yourself. You can also do that with a SQL statement:SELECT DISTINCT city FROM tableYou can also get the number or employees per city:SELECT city, COUNT(employee) AS num_employees FROM table GROUP BY cityPaging is done the same way regardless of the language, you need to know which page number you're on (or the starting record #) and the number of records per page, and with most databases you can use the LIMIT clause to get just the records for the page you're on. If you're using SQL Server, many versions do not support LIMIT and you need to use some hacks using temporary tables and TOP to get the records you're looking for without getting everything else. If you have SQL Server 2005 you can use the methods described here:http://blogs.msdn.com/sqlserver/archive/20...sql-server.aspxIf you have a version before 2005 then you need to use something like this:http://www.4guysfromrolla.com/webtech/042606-1.shtml

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...