易心asp分页类 v1.0

所属分类: 网络编程 / ASP编程 阅读数: 1875
收藏 0 赞 0 分享
易心asp分页类v1.0
复制代码 代码如下:

<% 
class Ex_SplitPageCls 
'========================================================================== 
'易心asp分页类v1.0 
'作者:易心 QQ:343931221 
'个人网站 www.ex123.net www.bo56.com  
'演示地址:www.ex123.net/show/page 
'转载请保留此信息 
'========================================================================== 
dim Ex_Rs 
dim Ex_columns'要提取的字段 
dim Ex_datafrom'数据表名 
dim Ex_strWhere'记录筛选条件 
dim Ex_order'sql排序 
dim Ex_idcount'记录总数 
dim Ex_pageSize'每页条数 
dim Ex_pageCount'总页数 
dim Ex_ids'获得本页要用到的id 
dim Ex_Sql'构造的sql语句 
dim Ex_page'当前显示页码 
dim Ex_Conn'数据库联接对象 
dim Ex_index'数据库记录当前位置 
dim Ex_id'主键字段 
private sub class_initialize 
set Ex_Rs=server.CreateObject("adodb.recordset") 
Ex_id="id" 
Ex_pageSize=20 
end sub 
private sub class_terminate 
Ex_rs.close 
set Ex_rs=nothing 
end sub 
'属性赋值: 
public property let letConn(str) 
        Ex_conn=str 
end property 
'属性赋值:sql语句 要查询的字段 带select 
public property let letColumns(str) 
        Ex_Columns=str 
end property 
'属性赋值:sql语句筛选条件部分 带where 
public property let letWhere(str) 
        Ex_strWhere=str 
end property 
'属性赋值:sql语句数据表 带from 
public property let letDataFrom(str) 
        Ex_dataFrom=str 
end property 
'属性赋值:sql语句排序部分 带order by 
public property let letOrder(str) 
        Ex_order=str 
end property 
'属性赋值:每页记录数 
public property let letPageSize(str) 
        Ex_pageSize=str 
end property 
'属性赋值:当前页数 
public property let letPage(str) 
        Ex_page=str 
end property 
'属性赋值:主表主键字段 
public property let letId(str) 
        Ex_Id=str 
end property 
'属性:获得记录总数 
public property get getRsCount 
        getRsCount=Ex_idCount 
end property 
'属性:获得页总数 
public property get getPageCount 
if(Ex_idcount>0) then'如果记录总数=0,则不处理 
        if(Ex_idcount mod Ex_pageSize=0)then'如果记录总数除以每页条数有余数,则=记录总数/每页条数+1 
                  Ex_pageCount=int(Ex_idcount/Ex_pageSize)'获取总页数 
        else 
                  Ex_pagecount=int(Ex_idcount/Ex_pageSize)+1'获取总页数 
        end if 
        getPageCount=Ex_pagecount 
else 
        getPageCount=0 
end if 
end property 
'属性:获得当前页数 
public property get getPage 
        getPage=Ex_Page 
end property 
'获得本页要用到的id 
private sub ids 
        dim i 
        Ex_sql="select "&Ex_Id&" "& Ex_datafrom &" " &" "&Ex_strWhere&" "&Ex_order 
        Ex_rs.open Ex_sql,Ex_conn,1,1 
        if not Ex_Rs.eof and not Ex_Rs.bof then 
                Ex_rs.pagesize =Ex_pageSize '每页显示记录数 
                Ex_Rs.absolutepage=CInt(Ex_Page) 
                Ex_idcount=Ex_rs.recordcount 
            if Ex_page < 1 then Ex_page = 1 
            if Ex_page > Ex_pagecount then Ex_page = Ex_pageCount 
            if Ex_pageCount > 0 then Ex_rs.absolutepage =Ex_page   
                for i=1 to Ex_rs.pagesize 
                if Ex_rs.eof then exit for   
                          if(i=1)then 
                           Ex_Ids=Ex_rs("id") 
                  else 
                           Ex_Ids=Ex_Ids &","&Ex_rs("id") 
                  end if 
                Ex_rs.movenext 
                next 
        end if 
        Ex_Rs.close 
end sub 
'返回本页要用到的记录集 
public function execute 
        ids 
        Ex_Sql=Ex_Columns&" "&Ex_dataFrom&" "&Ex_strWhere&" and id in("&Ex_ids&") "&Ex_order 
        Ex_Rs.open Ex_Sql,Ex_conn,1,1 
        Set execute=Ex_Rs 
end function 
end class 
%>
更多精彩内容其他人还在看

asp知识整理笔记4(问答模式)

这是关于asp知识整理的最后一份笔记,希望大家仔细阅读。
收藏 0 赞 0 分享

ASP基础知识VBScript基本元素讲解

这篇文章主要介绍了ASP基础知识VBScript基本元素的相关资料,需要的朋友可以参考下
收藏 0 赞 0 分享

ASP编码和解码函数详解

这篇文章主要介绍了ASP编码和解码函数的相关资料,需要的朋友可以参考下
收藏 0 赞 0 分享

ASP显示页面执行时间的方法

这篇文章主要介绍了ASP显示页面执行时间的方法,在本地测试一下输出页面需要多少时间,需要的朋友可以参考下
收藏 0 赞 0 分享

ASP基础入门第一篇(ASP技术简介)

本文将以 Active Server Pages 为中心,向你全面展示制作动态商业网站的步骤和技巧并通过大量的实例,让你在不断的理论和实践之中笑傲“网络”……
收藏 0 赞 0 分享

ASP基础入门第二篇(ASP基础知识)

这篇文章是ASP基础入门第二篇,第一篇展示了ASP动态网站设计的一些最基本的方法,相信通过实践各位对 ASP 已经有了最基本的了解,本文将进一步介绍ASP动态网站的一些基本技巧,需要的朋友可以参考下
收藏 0 赞 0 分享

ASP基础入门第三篇(ASP脚本基础)

通过前两篇的学习,相信各位已经对 ASP 的动态网站设计有了一个基本的概念和整体的印象。从本篇开始作者将从脚本语言的使用着手,由浅入深地带领大家探索 ASP 动态网站设计的真正奥秘。
收藏 0 赞 0 分享

ASP基础入门第四篇(脚本变量、函数、过程和条件语句)

大家在学习了脚本语言 VBScript 的变量、常量和过程的基本概念后,本期将继续向各位介绍 VBScript 的函数和语法。
收藏 0 赞 0 分享

ASP基础入门第五篇(ASP脚本循环语句)

在本文上两篇中,我们学习了脚本语言 VBScript 的变量、函数、过程和条件语句,本篇将继续给大家介绍 VBScipt 的循环语句,并对脚本语言在 ASP 中的应用加以总结。  
收藏 0 赞 0 分享

ASP基础入门第六篇(ASP内建对象Request)

从本篇开始作者从 ASP 内建对象着手,为大家详细剖析 ASP 的六个内建对象和各种组件的特性和方法,需要的朋友可以参考下
收藏 0 赞 0 分享
查看更多