最新更新 sitemap 网站制作设计本站搜索
网页设计
国外网站 韩国网站 个人主页 手提袋设计 CSS 网页特效 平面设计 网站设计 Flash CMS技巧 服装网站 php教程 photoshop 画册 服务器选用 数据库 Office
虚拟主机 域名注册 云主机 网页设计 客服QQ:8208442
当前位置:首页 > 编程开发 > asp教程

浅谈ACCESS数据库技术的2种分页核心思想技巧

日期:03-22    来源:中国设计秀    作者:cnwebshow.com

access分页技术思想A:tcp中国设计秀

tcp中国设计秀
 程序代码tcp中国设计秀
select top 分页数 * from 表 where 主键 not in (select top 第几页*分页数 主键 from 表 where 过滤条件) tcp中国设计秀
 tcp中国设计秀

tcp中国设计秀
ACCESS分页技术思想B:tcp中国设计秀

tcp中国设计秀
 程序代码tcp中国设计秀
select top 页大小 * from 表1 where 主键 <(select min(主键) from (select top 页大小 主键 from 表1 order by 主键 desc) as tblTmp) order by 主键 desctcp中国设计秀
  tcp中国设计秀

相比这两种设计思想,就大容量的数据而言,譬如一表几万条数据的显示的时候,就能明显的感觉出,前者比后者快了,因为前者不用建立后台临时表处理!,少了一个环节!不过简单的说,还是很容易理解的tcp中国设计秀

打个比方,我一页要五行数据,现在是第三页,那么第几页应该等于需要要的页数乘以记录!tcp中国设计秀

一个基于此思路的分页函数应用:tcp中国设计秀

tcp中国设计秀
 程序代码tcp中国设计秀

<%tcp中国设计秀
Function ShowClass(page, Fcount, order, desc)    tcp中国设计秀
    if page = "" or len(page) = 0 then page = 1    tcp中国设计秀
        tcp中国设计秀
     SkinStr = ""   tcp中国设计秀
     pageStr = ""   tcp中国设计秀
     SkinTatol = conn.execute("select count(*) from Skin")(0)    tcp中国设计秀
         tcp中国设计秀
     Filtwheres = "order by "&order" "&desc    tcp中国设计秀
         tcp中国设计秀
     if page > 1 then    tcp中国设计秀
         SkinSQL = "select top "& Fcount " Skin_ID,Skin_Name,Skin_Designer,Skin_PubDate,Skin_DesignerURL,Skin_DesignerMail,Skin_Geterip,Skin_GetTime,LocalSkinInfoPReview,Skin_RandromNumber,Skin_DownCouns,Skin_FromURL from Skin where Skin_ID not in (select top "& ((page -1)* Fcount)" Skin_ID from Skin "&Filtwheres") " & Filtwheres    tcp中国设计秀
     else    tcp中国设计秀
        SkinSQL = "select top "& Fcount " Skin_ID,Skin_Name,Skin_Designer,Skin_PubDate,Skin_DesignerURL,Skin_DesignerMail,Skin_GeterIP,Skin_GetTime,LocalSkinInfoPreview,Skin_RandromNumber,Skin_DownCouns,Skin_FromURL from Skin " & Filtwheres    tcp中国设计秀
     end if    tcp中国设计秀
   tcp中国设计秀
            '------------------ www.knowsky.com 分页栏 ---------------------    tcp中国设计秀
            total = SkinTatol '取总数    tcp中国设计秀
            per = Fcount '每页显示条数    tcp中国设计秀
            pages = total / per '总共的页数    tcp中国设计秀
                tcp中国设计秀
            If pages <> int(pages) then    tcp中国设计秀
                pages = int(pages) + 1    tcp中国设计秀
            Else   tcp中国设计秀
                pages = pages    tcp中国设计秀
            End If   tcp中国设计秀
                tcp中国设计秀
            If (page * per) >= total then    tcp中国设计秀
                bn = total    tcp中国设计秀
            Else   tcp中国设计秀
                bn = page * per    tcp中国设计秀
            End If   tcp中国设计秀
   tcp中国设计秀
            if pages <= 9 then    tcp中国设计秀
                if page > 5 then    tcp中国设计秀
                    a = page - 4    tcp中国设计秀
                    b = page + 4    tcp中国设计秀
                    if b > pages then b = pages    tcp中国设计秀
                else    tcp中国设计秀
                    a = 1    tcp中国设计秀
                    b = pages    tcp中国设计秀
                end if    tcp中国设计秀
            else    tcp中国设计秀
                if page > 5 then    tcp中国设计秀
                    a = page - 4    tcp中国设计秀
                    b = page + 4    tcp中国设计秀
                    if b > pages then b = pages    tcp中国设计秀
                else    tcp中国设计秀
                    a = 1    tcp中国设计秀
                    b = 9    tcp中国设计秀
                end if    tcp中国设计秀
            end if    tcp中国设计秀
                tcp中国设计秀
            '------------- start --------------------    tcp中国设计秀
            pageStr = pageStr & "<table><tr>"   tcp中国设计秀
            pageStr = pageStr & "<td><a href=""javascript:void(0);"" onclick=""IndexShow(1, "&per", '"&order"', '"&desc"', 'index')""><</a></td>"   tcp中国设计秀
                tcp中国设计秀
            For i = a to b    tcp中国设计秀
                if page = i then    tcp中国设计秀
                    pageStr = pageStr & "<td>" & i & "</td>"   tcp中国设计秀
                else    tcp中国设计秀
                    pageStr = pageStr & "<td><a href=""Javascript:void(0);"" onclick=""IndexShow("& i ", "&per", '"&order"', '"&desc"', 'index')"">" & i & "</a></td>"   tcp中国设计秀
                end if    tcp中国设计秀
            Next   tcp中国设计秀
                tcp中国设计秀
            pageStr = pageStr & "<td><a href=""javascript:void(0);"" onclick=""IndexShow("& pages ", "&per", '"&order"', '"&desc"', 'index')"">></a></td>"   tcp中国设计秀
            pageStr = pageStr & "</tr></table>"   tcp中国设计秀
            '------------- end --------------------    tcp中国设计秀
                tcp中国设计秀
                tcp中国设计秀
                tcp中国设计秀
            set SkinDB = conn.execute(SkinSQL)    tcp中国设计秀
            if SkinDB.bof or SkinDB.eof then    tcp中国设计秀
                SkinStr = SkinStr & "none"   tcp中国设计秀
            else    tcp中国设计秀
                web_len = 1    tcp中国设计秀
                SkinStr = SkinStr & "<table>"   tcp中国设计秀
                do while not SkinDB.eof    tcp中国设计秀
                    if web_len mod 4 = 0 then     tcp中国设计秀
                        Bleft = ""   tcp中国设计秀
                        Bright = "</tr>"   tcp中国设计秀
                    elseif web_len mod 4 = 1 then    tcp中国设计秀
                        Bleft = "<tr>"   tcp中国设计秀
                        Bright = ""   tcp中国设计秀
                    else    tcp中国设计秀
                        Bleft = ""   tcp中国设计秀
                        Bright = ""   tcp中国设计秀
                    end if    tcp中国设计秀
                        SkinStr = SkinStr & Bleft & "<td><a href=""javascript:;"" onmouseover=""this.className='skinb'"" class=""skina"" onmouseout=""this.className='skina'"" onFocus=""this.blur()""><p class=""skinp""><img src=""GetSkinsFolder/Preview/"&SkinDB("Skin_Name")"_"&SkinDB("Skin_RandromNumber")".jpg"" onerror=""this.src='GetSkinsFolder/Preview/Preview.jpg'"" class=""viewimgskin""><br>"&SkinDB("Skin_Name")"</p></a></td>" & Bright    tcp中国设计秀
                    web_len = web_len + 1    tcp中国设计秀
                SkinDB.movenext    tcp中国设计秀
                loop    tcp中国设计秀
                SkinStr = SkinStr & "</table>"   tcp中国设计秀
            end if     tcp中国设计秀
            ShowClass = pageStr & SkinStr     tcp中国设计秀
End Functiontcp中国设计秀
%>tcp中国设计秀

本文引用地址:/bc/article_46288.html
网站地图 | 关于我们 | 联系我们 | 网站建设 | 广告服务 | 版权声明 | 免责声明