急~~怎么在调用存储过程后,把得到的记录集分页显示?
从网上看到的例子,没太明白。代码如下:
--存储过程
CREATE procedure p_splitpage
@sql varchar(8000), --要执行的sql语句
@page int=1, --要显示的页码
@pageSize int, --每页的大小
@pageCount int=0 out, --总页数
@recordCount int=0 out --总记录数
as
set nocount on
declare @p1 int
exec sp_cursoropen @p1 output,@sql,@scrollopt=1,@ccopt=1,@rowcount=@pagecount output
set @recordCount = @pageCount
select @pagecount=ceiling(1.0*@pagecount/@pagesize)
,@page=(@page-1)*@pagesize+1
exec sp_cursorfetch @p1,16,@page,@pagesize
exec sp_cursorclose @p1
GO
--ASP调用代码:
set rsFile=cnAm.execute(session( "am_volfilesearchsql "))
if request( "page ")= " " or request( "page ")=0 or IsNumeric(request( "page "))=false then
m_page=1
else
m_page=cint(request( "page "))
end if
m_pagesize=2 '每页的条数
set cmd = server.CreateObject( "adodb.command ")
cmd.ActiveConnection = cnAm
cmd.CommandType = 4
cmd.CommandText = "p_SplitPage "
cmd.Parameters.Append cmd.CreateParameter( "@sql ",8,1,8000,session( "am_volfilesearchsql "))
cmd.Parameters.Append cmd.CreateParameter( "@page ",4,1,4,m_page)
cmd.Parameters.Append cmd.CreateParameter( "@pageSize ",4,1,4,m_pageSize)
cmd.Parameters.Append cmd.CreateParameter( "@pageCount ",4,2,4,m_pageCount)
cmd.Parameters.Append cmd.CreateParameter( "@recordCount ",4,2,4,m_recordCount)
set rsFile = cmd.Execute
set rsFile = rsFile.NextRecordSet
m_pageCount = cmd.Parameters( "@pageCount ").value
m_recordCount = cmd.Parameters( "@recordCount ").value
if m_pageCount = 0 then m_pageCount = 1
set rsFile = cmd.Execute