实现分页的例子-使用存储过程来实现分页

2016-01-29 18:16 45 1 收藏

实现分页的例子-使用存储过程来实现分页,实现分页的例子-使用存储过程来实现分页

【 tulaoshi.com - ASP 】

  在  网上 讨论 如何 实现 分页  有很多程序,我在这里向大家  介绍一种实现分页的新的方法,使用 存储过程 来实现分页
   由于 这段程序写的 比较早,那个时候 还没有 SQL 7,每一个 Varchar 只能 支持 255 个字符,所以 采取了一种比较笨的办法,如果大家有兴趣,请去  http://www.chinaasp.com/sqlbbs/default.asp 的数据库论坛发表意见,我会看情况,决定是否将这个 存储过程修改成为SQL 7 的存储过程;
   并在此起到 一个 抛砖引玉  的 作用
   这个 程序只能  达到  10 个 分页
if exists (select * from sysobjects where id = object_id('dbo.sp_productPage') and sysstat & 0xf = 4)
    drop procedure dbo.sp_productPage
GO

CREATE PROCEDURE sp_productPage
@intStart TINYINT=1,
@intEnd TINYINT=10
with ENCRYPTION
AS
  Declare @strProductID VARCHAR(8),@strProductName VARCHAR(20),
  @strSQL1 VARCHAR(100),
  @strSQL2 VARCHAR(100),
  @strSQL3 VARCHAR(100),
  @strSQL4 VARCHAR(100),
  @strSQL5 VARCHAR(100),
  @strSQL6 VARCHAR(100),
  @strSQL7 VARCHAR(100),
  @strSQL8 VARCHAR(100),
  @strSQL9 VARCHAR(100),
  @strSQL10 VARCHAR(100),
  @intCCount TINYINT,
  @intCount TINYINT,
  @i TINYINT
  select @i=1
  Declare cur_Product SCROLL CURSOR For
   Select ProductID,ProductName from KF_Product order by ProductID
   Select @intCCount=count(productId) From KF_Product
  open cur_Product
  Fetch ABSOLUTE @intStart From cur_Product Into @strProductID,@strProductName
  if @@FETCH_STATUS=0
    Select @intCount=@intStart
  Fetch cur_Product Into @strProductID,@strProductName
  if @@FETCH_STATUS=0
       Begin
         Select @intCount=@intCount+1
         Select @strSQL1='Select productId=''' + @strProductID + ''',productName=''' + @strProductName+ ''',ProductCount=' + convert(VARCHAR,@intCount)+',ProductSumCount='+ convert(VARCHAR,@intCCount) +' Union '
       End
   else
    Begin
       Select @strSQL1='Select productId=''' + @strProductID + ''',productName=''' + @strProductName+ ''',ProductCount=' + convert(VARCHAR,@intcCount)+',ProductSumCount='+ convert(VARCHAR,@intCCount)
       Goto EndPro
    End
  Fetch cur_Product Into @strProductID,@strProductName
  if @@FETCH_STATUS=0
       Begin
         Select @intCount=@intCount+1
         Select @strSQL2='Select productId=''' + @strProductID + ''',productName=''' + @strProductName+ ''',ProductCount=' + convert(VARCHAR,@intCount)+',ProductSumCount='+ convert(VARCHAR,@intCCount)+' Union '
       End
    else
       Begin
          Select @strSQL2='Select productId=''' + @strProductID + ''',productName=''' + @strProductName+ ''',ProductCount=' + convert(VARCHAR,@intcCount)+',ProductSumCount='+ convert(VARCHAR,@intCCount)
          Goto EndPro
       End
    Fetch cur_Product Into @strProductID,@strProductName
    if @@FETCH_STATUS=0
       Begin
         Select @intCount=@intCount+1
 &nb

来源:https://www.tulaoshi.com/n/20160129/1505115.html

延伸阅读
标签: Web开发
基于web的技术中,分页是一个老的不能再老的,但大家津津乐道的问题,随着xml技术的日渐应用,把xml应用到分页当中,也是一种可能,当然网上的教程很多,当我都是看得稀里糊涂,索性自己写一个,与大家分享、指正。 共有两个文件tmh.htm & tt.xml 源代码如下: tmh.htm _____________________________________________...
标签: Web开发
今天心情有点激动,想把"关于用DW+ASP实现分页技术的参考"分享给用DW+ASP做网页的朋友们.去掉只有"第一页,前一页,下一页,最后一页"的小痛苦 此效果最后的显示是:第N页[共*页] 1 2 3 4 5 6 7 8 9 10 。 用DW+ASP做网页时,在绑定记录集后,代码页里马上出现以下代码: %  Dim Recordset1  Dim Recordset1_numRows&nb...
标签: ASP
  建立表: CREATE TABLE [TestTable] ( [ID] [int] IDENTITY (1, 1) NOT NULL , [FirstName] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NULL , [LastName] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NULL , [Country] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL , [Note] [nvarchar] (2000) COLLATE Chinese_PRC_CI_...
标签: Web开发
代码如下: !-- //ASP分页函数 function ShowListPage(page,Pcount,TopicNum,maxperpage,strLink,ListName){     var alertcolor = '#FF0000';     maxperpage=Math.floor(maxperpage);     TopicNum=Math.floor(TopicNum);     p...
标签: Web开发
由于查询返回的数据量很大,超过10w条数据,因此需要对页面查询功能进行优化。放弃原有程序中使用DataGrid的做法,自己编写分页显示模块。     首先在页面上添加几个DIV:         div id="div_trackpoint" style=" border:solid 1px gray; height:230px; width:99%; overflow-y...

经验教程

452

收藏

86
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部