A SQL sample for pager
2011-03-18
The best way for pager of searching result is use pager in Database side, use stored procedure:
Here is a sample:
SELECT TOP pageSize *
From [TestDB].[dbo].[USER_EVENTS_LOG]
Where [LogEventsUserID] not in
(select top pageSize * pageID [LogEventsUserID]
FROM [TestDB].[dbo].[USER_EVENTS_LOG]
order by CreateTime desc)
order by CreateTime desc
(the pageID start from 0 above, and also it is descent order)