zoukankan      html  css  js  c++  java
  • uniquery 配合 mssql 自带存储过程实现分页

    --使用系统存储过程实现的通用分页存储过程
    -- 此过程原作者,应该是:邹健老前辈
    CREATE PROC sp_PageView   
    @sql         ntext,     --要执行的sql语句
    @PageCurrent int=1,     --要显示的页码
    @PageSize    int=10,    --每页的大小
    @PageCount   int OUTPUT --总页数
    AS
    SET NOCOUNT ON
    DECLARE @p1 int
    --初始化分页游标
    EXEC sp_cursoropen 
        @cursor=@p1 OUTPUT,
        @stmt=@sql,
        @scrollopt=1,
        @ccopt=1,
        @rowcount=@PageCount OUTPUT
    
    --计算总页数
    IF ISNULL(@PageSize,0)<1 
        SET @PageSize=10
    SET @PageCount=(@PageCount+@PageSize-1)/@PageSize
    IF ISNULL(@PageCurrent,0)<1 OR ISNULL(@PageCurrent,0)>@PageCount
        SET @PageCurrent=1
    ELSE
        SET @PageCurrent=(@PageCurrent-1)*@PageSize+1
    
    --显示指定页的数据
    EXEC sp_cursorfetch @p1,16,@PageCurrent,@PageSize
    
    --关闭分页游标 
    EXEC sp_cursorclose @p1
    declare @I int
    execute SP_PageVIew 'SELECT * FROM Item',1,10,@I output
    select @I
    
    
    
    因为此分页过程返回三个数据集。
    通过:
      UniQuery1.OpenNext;  分别取出自己要的数据。
    

      

  • 相关阅读:
    网络编程
    C 语言 const
    C 语言 链表
    C 语言 按位计算
    C 语言 格式化输出输入
    C 语言 结构类型 联合
    C 语言 结构类型 结构
    C 语言 结构类型 枚举
    bash shell configuration
    sed usage
  • 原文地址:https://www.cnblogs.com/starluck/p/4269684.html
Copyright © 2011-2022 走看看