程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> ASP編程 >> ASP技巧 >> 淺談ACCESS數據庫技術的2種分頁核心思想

淺談ACCESS數據庫技術的2種分頁核心思想

編輯:ASP技巧

Access分頁技術思想A:


 程序代碼
select top 分頁數 * from 表 where 主鍵 not in (select top 第幾頁*分頁數 主鍵 from 表 where 過濾條件)
 


Access分頁技術思想B:


 程序代碼
select top 頁大小 * from 表1 where 主鍵 <(select min(主鍵) from (select top 頁大小 主鍵 from 表1 order by 主鍵 desc) as tblTmp) order by 主鍵 desc
  

相比這兩種設計思想,就大容量的數據而言,譬如一表幾萬條數據的顯示的時候,就能明顯的感覺出,前者比後者快了,因為前者不用建立後台臨時表處理!,少了一個環節!不過簡單的說,還是很容易理解的

打個比方,我一頁要五行數據,現在是第三頁,那麼第幾頁應該等於需要要的頁數乘以記錄!

一個基於此思路的分頁函數應用:


 程序代碼

<%
Function ShowClass(page, Fcount, order, desc)   
    if page = "" or len(page) = 0 then page = 1   
       
     SkinStr = ""  
     pageStr = ""  
     SkinTatol = conn.execute("select count(*) from Skin")(0)   
        
     Filtwheres = "order by "&order" "&desc   
        
     if page > 1 then   
         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   
     else   
        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   
     end if   
  
            '------------------ www.knowsky.com 分頁欄 ---------------------   
            total = SkinTatol '取總數   
            per = Fcount '每頁顯示條數   
            pages = total / per '總共的頁數   
               
            If pages <> int(pages) then   
                pages = int(pages) + 1   
            Else  
                pages = pages   
            End If  
               
            If (page * per) >= total then   
                bn = total   
            Else  
                bn = page * per   
            End If  
  
            if pages <= 9 then   
                if page > 5 then   
                    a = page - 4   
                    b = page + 4   
                    if b > pages then b = pages   
                else   
                    a = 1   
                    b = pages   
                end if   
            else   
                if page > 5 then   
                    a = page - 4   
                    b = page + 4   
                    if b > pages then b = pages   
                else   
                    a = 1   
                    b = 9   
                end if   
            end if   
               
            '------------- start --------------------   
            pageStr = pageStr & "<table><tr>"  
            pageStr = pageStr & "<td><a href=""Javascript:void(0);"" onclick=""IndexShow(1, "&per", '"&order"', '"&desc"', 'index')""><</a></td>"  
               
            For i = a to b   
                if page = i then   
                    pageStr = pageStr & "<td>" & i & "</td>"  
                else   
                    pageStr = pageStr & "<td><a href=""Javascript:void(0);"" onclick=""IndexShow("& i ", "&per", '"&order"', '"&desc"', 'index')"">" & i & "</a></td>"  
                end if   
            Next  
               
            pageStr = pageStr & "<td><a href=""Javascript:void(0);"" onclick=""IndexShow("& pages ", "&per", '"&order"', '"&desc"', 'index')"">></a></td>"  
            pageStr = pageStr & "</tr></table>"  
            '------------- end --------------------   
               
               
               
            set SkinDB = conn.execute(SkinSQL)   
            if SkinDB.bof or SkinDB.eof then   
                SkinStr = SkinStr & "none"  
            else   
                web_len = 1   
                SkinStr = SkinStr & "<table>"  
                do while not SkinDB.eof   
                    if web_len mod 4 = 0 then    
                        Bleft = ""  
                        Bright = "</tr>"  
                    elseif web_len mod 4 = 1 then   
                        Bleft = "<tr>"  
                        Bright = ""  
                    else   
                        Bleft = ""  
                        Bright = ""  
                    end if   
                        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   
                    web_len = web_len + 1   
                SkinDB.movenext   
                loop   
                SkinStr = SkinStr & "</table>"  
            end if    
            ShowClass = pageStr & SkinStr    
End Function
%>

 

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved