易心asp分页类 v1.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
%>
代码如下:
<%
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
%>