Linux中国 Linux中国门户站!
设为主页 设为主页
收藏本站 收藏本站
 
当前位置 :首页 ->编程语言 ->ASP.NET ->正文

存储过程的分页!!

来源:Linuxdby.com 作者:Webmaster 时间:2007-04-28 点击: [收藏] [投稿]
create proc up_GetTopicList
       @a_strForumID varchar(50) ,
       @a_intPageNo int  ,
       @a_intPageSize int
as
   /*定义局部变量*/
   declare @intBeginID         int
   declare @intEndID           int
   declare @intRootRecordCount int
   declare @intPageCount       int
   declare @intRowCount        int
   /*关闭计数*/
   set nocount on
   
  
   /*求总共根贴数*/
   select @intRootRecordCount = count(*) from bbs_topic where fatherid=0 and forumid=@a_strForumID
   if (@intRootRecordCount = 0)    --如果没有贴子,则返回零


       return 0
       
   /*判断页数是否正确*/
   if (@a_intPageNo - 1) * @a_intPageSize > @intRootRecordCount
      return (-1)

   /*求开始rootID*/
   set @intRowCount = (@a_intPageNo - 1) * @a_intPageSize + 1
   /*限制条数*/
   set rowcount @intRowCount
   select @intBeginID = rootid from bbs_topic where fatherid=0 and forumid=@a_strForumID
          order by tid desc

   /*结束rootID*/
   set @intRowCount = @a_intPageNo * @a_intPageSize
   /*限制条数*/
   set rowcount @intRowCount
   select @intEndID = rootid from bbs_topic where fatherid=0 and forumid=@a_strForumID
          order by tid desc

   /*恢复系统变量*/
   set rowcount 0
   set nocount off   

   select a.tid , a.layer , a.forumid , a.subject , a.faceid , a.hits , a.posttime , a.UserID , a.fatherid , a.rootid ,
         'Bytes' = datalength(a.content) , b.loginname  , b.Email  , b.HomePage , b.Signature , b.Point
     from bbs_topic as a join BBS_User as b on a.UserID = b.uid
     where Forumid=@a_strForumID and a.rootid between @intEndID and @intBeginID
         order by a.rootid desc , a.ordernum desc
   return(@@rowcount)
   --select @@rowcount
go    

怎么操作就不贴了!!大家好好看看,






 如果您对本文有任何疑问或者建议,请到讨论区发表您的意见: >> 论坛入口 <<



上一篇:com.joybase.DB.dll源代码(2)   下一篇:asp+中文教程(二)---- Asp+ Web Forms

文章评论】 【收藏本文】 【推荐好友】 【打印本文】 【我要投稿】 【论坛讨论
更多相关文章
Power by linux-cn.com 粤ICP备05006655号