人人做人人澡人人爽欧美,国产主播一区二区,久久久精品五月天,羞羞视频在线观看免费

當前位置:蘿卜系統下載站 > 技術開發教程 > 詳細頁面

asp + oracle 分頁辦法

asp + oracle 分頁辦法

更新時間:2022-08-16 文章作者:未知 信息來源:網絡 閱讀次數:

代碼如下:

'其中注釋中有 ###的需要用戶設置
'其中注釋中有 參數傳遞 ** 的 說明要通過參數 傳遞。


'定義變量
dim tOption                  '查詢條件
dim tOrder                   '排序字符串     
dim tOrderField              '排序字段        可通過參數獲得:order_field
dim tOrderDirection          '排序方向        可通過參數獲得:order_direction

dim tPageSize                '頁大小
dim tTotalCount              '總記錄數        可通過參數獲得:t_count
dim tPageCount               '頁數
dim tCurPage                 '當前頁號        可通過參數獲得:page

dim tTableName               '表或者視圖名

dim tFieldList               '查詢的字段列表
dim tPageField               '用于分頁的字段

dim r_count                  '查得的記錄數


set rs=server.createobject("adodb.recordset")        '記錄集對象

'排序處理
tOrderField=Request("order_field")                   '獲得排序字段(參數傳遞 **)
tOrderDirection=Request("order_dir")                 '獲得排序方向(參數傳遞 **)

if(tOrderField="") then tOrderField="item_code"       ' ### 設置默認排序字段
if(tOrderDirection="") then tOrderDirection="asc"     ' ### 設置默認排序方向

tOrder=" order by " & tOrderField & " " & tOrderDirection & " "   '生成排序字符串


'定義參數
tPageSize=find_rs_count        ' ### 設置頁大小
tTableName="view_select1"      ' ### 設置與查詢的表格或視圖
tFieldList=" * "               ' ### 欲查詢的字段列表
tPageField="item_code"         ' ### 設置一個主鍵或唯一索引的字段 ,用于分頁計算


'頁數處理
tCurPage=Request("page")             '獲得當前頁(參數傳遞 **)
tTotalCount=Request("t_count")       '獲得總頁數(參數傳遞 **)

if(tCurPage="") then tCurPage=1
if(cint(tCurPage)=0) then tCurPage=1
if(tPageCount="") then tPageCount =1
if(cint(tPageCount)=0) then tPageCount=1

' 構造查詢條件,根據具體的程序,肯定不一樣。但是最后的條件必須是“ where ??? ”
tOption=" issue_flag='Y'"                      ' ### 設置條件
if f_c<>"" then tOPtion= tOPtion & f_c         ' ### 設置條件

if trim(tOption)="" then
     tOption = " where 1=1 "   '如果沒有條件,就自己加一個。
else
     tOption= " where " & tOPtion
end if

   
  
     '構造查詢字符串,這個分頁程序的核心,此查詢串是我們只下載當前頁所需的記錄
 
sss="select * from (select rownum r_n,temptable.* from (select  " & tFieldList & " from " & tTableName & " " & tOption & " " & tOrder & ") temptable ) where r_n between " & cstr((tCurPage -1) * tPageSize +1) & " and " & cstr(tCurPage * tPageSize)  
 
 '執行主查詢,獲得相應記錄集
 Call ConnDataBase()                     '  ### 建立數據庫連接
    rs.cursorlocation=3
    rs.open conStr,conn,3,1                 '執行查詢
    r_count= rs.recordcount


   '當還沒有查詢過總記錄數時 并且 總的記錄數超過了頁大小時 ,查詢當前條件下的總的記錄數
   if(r_count>=tPageSize or tCurPage>1) and tTotalCount=0 then
      set rr=conn.execute("select count(*) from " & tTableName & " " & tOption)
      tTotalCount=rr(0)
      rr.close()
      set rr=nothing
   end if   
   if(cint(tTotalCount)=0) then tTotalCount=r_count '如果總記錄為0,將當前差得的記錄集的記錄數設置為總記錄數,說明當前的總記錄數小于頁大小
  
   '利用頁大小和總記錄數 計算頁數
   if(cint(tTotalCount)>cint(tPageSize)) then
  tPageCount=cint((cint(tTotalCount) \ cint(tPageSize)))
  if(cint(tTotalCount) mod cint(tPageSize))>0 then
      tPageCount =tPageCount +1
  end if
   end if
 
   tCurPage=cint(tCurPage)
   tPageCount=cint(tPageCount)


'  ---------------------------------------------------------------------


溫馨提示:喜歡本站的話,請收藏一下本站!

本類教程下載

系統下載排行

網站地圖xml | 網站地圖html
主站蜘蛛池模板: 翁源县| 台东市| 饶平县| 宣化县| 华亭县| 呼和浩特市| 江津市| 新宁县| 岳池县| 濉溪县| 丽水市| 禄劝| 河源市| 松江区| 邢台市| 四川省| 巫溪县| 榕江县| 青浦区| 连江县| 远安县| 清苑县| 神池县| 甘南县| 夏邑县| 襄樊市| 大田县| 西青区| 勃利县| 塘沽区| 钟山县| 舞钢市| 宁阳县| 永嘉县| 通州市| 海城市| 乌什县| 宜宾县| 灯塔市| 商河县| 隆林|