|
strsql=strsql&") "&vOrderBy end if '------------------------------------------------------------------- set pageRs=server.CreateObject("adodb.recordset") pageRs.open strsql,conn,0,1 errMsg "记录分页" end function '------sql用存储过程分页------------------------------------------------------ public function sqlPage() on error resume next Set sqlPage=server.CreateObject("Adodb.RecordSet") Set Cm=Server.CreateObject("Adodb.Command") Cm.CommandType = 4 Cm.ActiveConnection = conn Cm.CommandText="sp_Util_Page" Cm.parameters(1) = vPgFields Cm.parameters(2) = vTbName Cm.parameters(3) = vConditions Cm.parameters(4) = vOrderBy Cm.parameters(5) = vPKey Cm.parameters(6) = vCurrPg Cm.parameters(7) = vPgSize Cm.parameters(8) = vRsCount() Cm.parameters(9) = "" sqlPage.CursorLocation = 3 sqlPage.LockType = 1 sqlPage.Open Cm errMsg "记录分页" end function '---------------------------------------------------------------------------- '关闭记录集objRs '---------------------------------------------------------------------------- Public Function cRs(ByVal ObjRs) ObjRs.close() Set ObjRs = Nothing End Function '----------------------分页的页码导航--------------------------------------- public function pageNav() iRsCount=vRsCount()'总记录数 mypage=vCurrPg'当前页数 PgCount=vPgCount()'总页数 prePage=mypage-1 if prePage<1 then prePage=1 end if nextPage=mypage+1 if nextPage>PgCount then nextPage=PgCount end if pagestr="<div id=""fy""><span id=""rpc"">总共有"&iRsCount&"条记录 "&mypage&"/"&PgCount&"</span>" pagestr=pagestr&"<a href='?currpage=1' class='aW'>首页</a><a href='?currpage="&prePage&"' class='aW'>前一页</a>" if (mypage-1) mod 4=0 then firstPage=mypage elseif int((mypage-1)/4)=0 then firstPage=1 else firstPage=int((mypage-1)/4)*4+1 end if endPage=firstPage+4 astr="" for i=firstPage to endPage astr=astr&"<a href='?currpage="&i&"'" if Cstr(mypage)=Cstr(i) then astr=astr&" id='currP'" end if astr=astr&">"&i&"</a>" if i>PgCount-1 then exit for next astr=astr&"<a href='?currpage="&nextPage&"' class='aW'>后一页</a><a href='?currpage="&PgCount&"' class='aW'>尾页</a></div>" pagestr=pagestr&astr pageNav=pagestr end function '输出带分页功能的table Function showTb(ByVal TbTil) set rsTb=pageRs()'若是存储过程就调用sqlPage() tbRs= rsTb.getrows() cRs(rsTb) iTblRow=Ubound(tbRs,2) iTblCol=Ubound(TbTil) tbStr="<table border='0' cellspacing='0' cellpadding='0'><tbody>" for r1=0 to iTblCol tr1=tr1&"<td width='"&split(TbTil(r1),"|")(1)&"'>"&split(TbTil(r1),"|")(0)&"</td>" |
|
【收藏】【打印】【进入论坛】 |
|
|
|
|
|
|
|