DataList分页存储过程的写法??
我用Datalist手动分页,我存储过程如下:
ALTER PROCEDURE dbo.getallNews
@currenpage int,--当前页
@pagesize int --每页数量
AS
declare @a nvarchar(50)
declare @b nvarchar(50)
declare @v_str nvarchar(2000)
set @a=convert(nvarchar,@pagesize)
set @b= convert(nvarchar,@pagesize*(@currenpage-1))
set @v_str= 'select top '+@a+ ' * from News where NewsID not in (select top '+@b+ ' NewsID from News order by NewsID) order by NewsID '
set @v_str= 'select t.* from ( '+@v_str+ ')t order by t.UploadDate desc '
EXECUTE sp_executesql @v_str
RETURN
这是先分页后排序?这样有个问题 , 时间排序是根据页来排的,
我想先排序后分页 ,请问有没有好点的存储过程
------解决方案--------------------可以试试我写的这个分页存储过程代码工具,可以先排序再分页:
http://www.webdiyer.com/AspNetPager/utility/sqlspgen.aspx