If its an SQL Server database your binding it to i would use a stored procedure like this:
CREATE PROCEDURE dbo.GetDocuments
@PageSize int,
@PageNumber int
AS
DECLARE @Ignore int
DECLARE @LastID int
IF @PageNumber > 1
BEGIN
/* For pages > 1 compute how many records to ignore,
set ROWCOUNT and SELECT ID into @LastID */
SET @Ignore = @PageSize * (@PageNumber - 1)
SET ROWCOUNT @Ignore
SELECT @LastID = ID
&nbs p; FROM Documents
&nbs p; ORDER BY ID DESC
END
ELSE
BEGIN
/* For page #1 just set rowcount to pagesize */
SET ROWCOUNT @PageSize
END
/* Set rowcount to @PageSize and
SELECT page for output (note the WHERE clause) */
SET ROWCOUNT @PageSize
SELECT *
&nbs p; FROM Documents
&nbs p; WHERE ID < @LastID
&nbs p; ORDER BY ID DESC
SET ROWCOUNT 0
GO
|
Mart.