Published in: SQL
CREATE PROCEDURE [dbo].[selRecords] @id int, @iRowStart int, @iRowEnd int AS BEGIN SET NOCOUNT ON; WITH RowEntries AS ( SELECT ROW_NUMBER() OVER (ORDER BY datefield DESC) AS Row,id,firstname,lastname FROM [TABLE] WHERE id = @id ) SELECT id,firstname,lastname FROM RowEntries WHERE Row BETWEEN @iRowStart AND @iRowEnd END ASP Code: dim Id: Id = request.querystring("id") dim iCurrentPage: iCurrentPage = request.querystring("p") dim iRecordsPerPage: iRecordsPerPage = 10 dim iTotalRecords: iTotalRecords = getTotalRecords(Id) 'build this function if len(iCurrentPage) = 0 or not isnumeric(iCurrentPage) then _ iCurrentPage = 1 iRowStart = ((iCurrentPage - 1) * iRecordsPerPage + 1) iRowEnd = (iRowStart + (iRecordsPerPage-1)) sql= "dbo.selRecords " & Id & ", "&iRowStart&", " & iRowEnd if (iCurrentPage > 1) then _ response.write "<div style=""float:left;""><a href="""&scriptName&"?id="&Id&"&p="&(iCurrentPage-1)&"""><< Previous</a></div>" if (iRowEnd <= iTotalRecords) then _ response.write "<div style=""float:right;""><a href="""&scriptName&"?id="&Id&"&p="&(iCurrentPage+1)&""">Next >></a></div>"
Comments
Subscribe to comments
- Posted By: krisdb on July 12, 2007
You need to login to post a comment.
