⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 0053.htm

📁 ASP教程宝典 书籍语言: 简体中文 书籍类型: 网络编程 授权方式: 免费软件 书籍大小: 500 KB
💻 HTM
字号:
<html>

<head>
<title>新时代软件教程:操作系统 主页制作 服务器 设计软件 网络技术 编程语言 文字编辑</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style>
<!--
body, table {font-size: 9pt; font-family: 宋体}
a {text-decoration:none}
a:hover {color: red;text-decoration:underline}
.1  {background-color: rgb(245,245,245)}
-->
</style>
</head>
<p align="center"><script src="../../1.js"></script></a>
    <p align="center"><big><strong>存储过程分页</strong></big></p>

<div align="right">---(文/bigeagle)</div>

<pre>

if exists(select * from sysobjects where ID = object_id(&quot;up_TopicList&quot;))
   drop proc up_TopicList
go

create proc up_TopicList 
   @a_ForumID int , @a_intDays int , @a_intPageNo int , @a_intPageSize tinyint
   as
     declare @m_intRecordNumber int
     declare @m_intStartRecord  int
     select @m_intRecordNumber = @a_intPageSize * @a_intPageNo
     select @m_intStartRecord = @a_intPageSize * (@a_intPageNo - 1) + 1

     if @a_intDays = 0                      --如果不限定天数
       begin
         /*求符合条件记录数*/
         select &quot;RecordCount&quot; = count(*)                         
                from BBS where Layer=1 and ForumID = @a_ForumID 

         /*输出纪录*/
         /*首先定义可滚动光标*/
         set rowcount @m_intRecordNumber
         declare m_curTemp Scroll cursor 
           for
              select a.ID ,a.Title , d.UserName , a.FaceID ,
                'ContentSize' = datalength(a.Content) , 
                'TotalChilds' = (select sum(TotalChilds) 
               from BBS as b 
               where a.RootID = b.RootID) ,
              'LastReplyTime' = (select max(PostTime) 
                   from BBS as c 
                   where a.RootID = c.RootID)
                         from BBS as a 
                                     join BBSUser as d on a.UserID = d.ID 
                                where Layer=1 and ForumID = @a_ForumID 
                                order by RootID desc , Layer , PostTime
               open m_curTemp
               fetch absolute @m_intStartRecord from m_curTemp
               while  @@fetch_status = 0 
                      fetch next from m_curTemp

               set rowcount 0 
               /*清场*/       
               CLOSE m_curTemp
               DEALLOCATE m_curTemp
          end                      
                          
       else                                --如果限定天数          

          begin
                /*求符合条件记录数*/
                select &quot;RecordCount&quot; = count(*)                         
                       from BBS where Layer=1 and ForumID = @a_ForumID 
                                      and dateadd(day , @a_intDays , PostTime) &gt; getdate() 

               /*输出纪录*/
               /*首先定义可滚动光标*/
               set rowcount @m_intRecordNumber
               declare m_curTemp Scroll cursor 
                       for
                          select a.ID ,a.Title , d.UserName , a.FaceID ,
                                'ContentSize' = datalength(a.Content) , 
                                'TotalChilds' = (select sum(TotalChilds) 
                                                        from BBS as b 
                                                        where a.RootID = b.RootID) ,
                                'LastReplyTime' = (select max(PostTime) 
                                                          from BBS as c 
                                                          where a.RootID = c.RootID)
                                from BBS as a 
                                     join BBSUser as d on a.UserID = d.ID 
                                where Layer=1 and ForumID = @a_ForumID 
                                      and dateadd(day , @a_intDays , PostTime) &gt; getdate() 
                                order by RootID desc , Layer , PostTime
               open m_curTemp
               fetch absolute @m_intStartRecord from m_curTemp
               while  @@fetch_status = 0 
                      fetch next from m_curTemp

               set rowcount 0 
               /*清场*/       
               CLOSE m_curTemp
               DEALLOCATE m_curTemp
          end                                                
go

</pre>
注:若在asp中调用存储过程的command对象为cm,则set rs=cm.execute,然后用set rs=rs.nextrecordset取下一条记录。

  </table>
<p align="center"><script src="../../2.js"></script></a>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -