asp分页的一个类
asp分页的一个类 
在50,000条记录下测试过,速度比ado的那个要快多了 

<%

'************************************************************************************
'具体用法
dim strdbpath
dim connstr
dim mp
set mp = new mypage
strdbpath = "fenye/db.mdb"
connstr  = "provider=microsoft.jet.oledb.4.0;data source="
connstr  = connstr & server.mappath(strdbpath)
set conn  = server.createobject("adodb.connection")
conn.open connstr
set rs = mp.execute("select * from table1",conn,29)
while not rs.eof
    response.write rs("aaaa")&"
"
    rs.movenext
wend
mp.pagedispaly()
'************************************************************************************
class mypage
    private mypage_conn,mypage_strsql,mypage_totalstrsql,mypage_rs,mypage_totalrs
    private mypage_pagesize
    private mypage_pageabsolute,mypage_pagetotal,mypage_recordtotal
    private mypage_url
    public property let conn(strconn)
    set mypage_conn = strconn
    end property

    public property let pagesize(intpagesize)
        mypage_pagesize = cint(intpagesize)
    end property

    public function pageexecute(strsql)
        mypage_pageabsolute = mypage_pageabsoluterequest()
        mypage_totalstrsql = formatmypage_totalstrsql(strsql) 
        set mypage_totalrs = mypage_conn.execute(mypage_totalstrsql)
        mypage_recordtotal = mypage_totalrs("total")
        mypage_pagetotal = cint(mypage_recordtotal/mypage_pagesize)
        mypage_strsql = formatmypage_strsql(strsql)
        set mypage_rs = mypage_conn.execute(mypage_strsql)
        dim i
        i = 0 
        while not mypage_rs.eof and  i<(mypage_pageabsolute-1)*mypage_pagesize
            i = i + 1
            mypage_rs.movenext
        wend
        set pageexecute = mypage_rs 
    end function

    public function execute(strsql,strconn,intpagesize)
        conn = strconn
        pagesize = intpagesize
        set execute = pageexecute(strsql)
    end function

    public function pagedispaly()
        mypage_url = readmypage_url
        firstpagetag = "9"  '|<<
        lastpagetag = ":"  '>>|
        previewpagetag = "7"  '<<
        nextpagetag = "8"  '>>
        dim strand
        if instr(mypage_url,"?")=0 then
            strand = "?"
        else
            strand = "&"
        end if
        response.write ""
        response.write ""
        response.write "
"
        response.write  "页次:"&mypage_pageabsolute&"/"&mypage_pagetotal&"页 "
        response.write  "主题数:"&mypage_recordtotal
        response.write ""
        response.write "
"
        response.write  "分页:"
        if mypage_pageabsolute>10 then
            response.write  ""&firstpagetag&""
            response.write  "
"&previewpagetag&""
        else
            response.write  firstpagetag
            response.write  previewpagetag
        end if
        response.write " "
        dim currentstartpage,i
        i = 1
        currentstartpage=(cint(mypage_pageabsolute)\10)*10+1
        if cint(mypage_pageabsolute) mod 10=0 then
            currentstartpage = currentstartpage - 10
        end if
        while i<11 and currentstartpage
相关文章