当前位置: 首页 > 图文教程 > 网络编程 > ASP > 实现分页的例子-使用存储过程来实现分页

ASP
介绍一下GETROWS的用法
一个在vbscript中读取cookie的程序函数
用err.raise自定义错误信息
一段返回随机记录的代码
基于ACCESS数据库的纯asp论坛制作心得
不用Golobal.asa和session实现在线人数统计
在ASP里建表
结束ADOVB.INC的办法
存储过程分页
友情连接浏览器
怎样使用ASP实现Ping
用ASP读取Windows标准INI格式文件
使用ActiveX控件开发网页常见的问题
两个获取http页面的c#函数
将html源代码规范化,转换成XSL代码的asp工具
已调试好的asp程序在VB中转换为组件的技巧
关于如何动态地在同一页面实现两个互传
关于图片与文本同存在数据库中的具体思路
实现分页的例子-使用存储过程来实现分页
使用索引服务器- 使用索引服务器的对象

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 18 ::
收藏到网摘: n/a

  在  网上 讨论 如何 实现 分页  有很多程序,我在这里向大家  介绍一种实现分页的新的方法,使用 存储过程 来实现分页
   由于 这段程序写的 比较早,那个时候 还没有 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'