Paging in VBScript
Creating a paging class was probably one of the more challenging pieces logic that I’ve ever had to create. I had a very difficult time stabilizing it, and make sure that it would reliably return the results I needed.
Well, after many hours of work, I got it to work quite well, and the fruits of my labour are for you to behold and possess!
You will note that you will require to get a recordset from the database to populate the class on your own. The class is well documented, but if you have any questions, please don’t hesitate to message me here on this blog.
The paging class does not control your recordset directly. It simply provides a user interface and will resolve what you provide it. The class requires that you provide a querystring parameter called “offset” in your URL. If you want to show the user a 10 records from 60 to 69 from a set of 100, then you’d set the offset parameter to “offset=6″.
Note that you must pass the total number of records (rowsLength) to the instance of the class before calling the page method.
Set page = New Paging
page.RowsLength = 208 ‘Note that this is manditory before calling the WritePaging method.
Set page = Nothing
You will have to control your recordset yourself. If you have a stored procedure that requires you to provide it input on which 10 records you wish to extract from a particular recordset of 100, then you could extra that number from the querystring itself. I created a stored procedure myself that will take the offset number and provide me with 10 records withing that range. So if my offset is set at 5 (offset=5), then my stored procedure will take that number 5 and return me 10 records ranging from 50 to 59.