国产片侵犯亲女视频播放_亚洲精品二区_在线免费国产视频_欧美精品一区二区三区在线_少妇久久久_在线观看av不卡

服務器之家:專注于服務器技術及軟件下載分享
分類導航

PHP教程|ASP.NET教程|Java教程|ASP教程|編程技術|正則表達式|C/C++|IOS|C#|Swift|Android|VB|R語言|JavaScript|易語言|vb.net|

服務器之家 - 編程語言 - ASP教程 - asp的通用數據分頁類

asp的通用數據分頁類

2019-10-21 10:24asp代碼網 ASP教程

通用分頁類,以后寫分頁顯示數據時就輕松多啦.直接調用此類,然后再Execute即可以取得當前頁的所有數據. 此類所做的工作是只取得當前頁的數據,和總頁數和總記錄數等等數據.

通用數據分頁類

通用分頁類,以后寫分頁顯示數據時就輕松多啦.直接調用此類,然后再Execute即可以取得當前頁的所有數據.

此類所做的工作是只取得當前頁的數據,和總頁數和總記錄數等等數據.

ASP代碼:

  1. <%  
  2. '/*****************************分頁顯示類**************************  
  3. '/* 作者:哇哇魚  
  4. '/* 日期:2004年11月18日  
  5. '/* 作用:取得某一頁的數據并返回給外部  
  6. '/* 說明示例:  
  7. '/* Dim MyPage=New PageClass  
  8. '/* MyPage.Conn=Conn                '設置連接對象  
  9. '/* MyPage.PageSize=20                 '設置一頁顯示多少條數據 (默認為10條)  
  10. '/* MyPage.CurPage=2                   '設置當前要顯示的頁碼  
  11. '/*''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''  
  12. '/* MyPage.TableName="Member"       '設置表名  
  13. '/* MyPage.Fields="ID,MemberName,MemberPass"   '設置顯示字段列表  
  14. '/* MyPage.Condition="ID>100"          '設置查詢條件  
  15. '/* MyPage.OrderBy="ID DESC"           '設置排序條件(一定要設置該屬性)  
  16. '/* Set PageRs=MyPage.Execute          '返回當前第2頁的數據(RecordSet對象),如果出錯則返回Nothing值  
  17. '/*''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''  
  18. '/*'以上的定義也可以用以下的方法:ExecuteBy("表名","字段列表","查詢條件","排序條件")  
  19. '/* Set PageRs=MyPage.ExecuteBy("Member","ID,MemberName,MemberPass","ID>100","ID DESC")  
  20. '/*''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''  
  21. '/* PageCount=MyPage.PageCount         '返回頁碼總數  
  22. '/* RecordCount=MyPage.RecordCount     '返回記錄總數  
  23. '/* NextPage=MyPage.NextPage           '返回下頁的頁碼  
  24. '/* PrePage=MyPage.PrePage             '返回上一頁的頁碼  
  25. '/*****************************************************************  
  26. Class PageClass  
  27.     Private Connection               '連接數據庫的外部Connection對象  
  28.     Private Rs  
  29.     Private List_Fields  
  30.     Private Table_Name  
  31.     Private Query_Where  
  32.     Private OrderBy_SQL              '字段排序語句部分  
  33.     Private Page_Count               '返回當前查詢的記錄頁總數  
  34.     Private Page_Size                '設置一頁顯示多少條的記錄  
  35.     Private Cur_Page                 '設置當前的頁碼  
  36.     Private Record_Count             '返回當前查詢的記錄總數  
  37.  
  38.     '/****************設置Connection對象****************************  
  39.     Public Property Let Conn(ByRef ObjConn)  
  40.         Set Connection=ObjConn  
  41.     End Property  
  42.     Public Property Get Conn()  
  43.         Set Conn=Connection  
  44.     End Property  
  45.     '/****************End******************************************  
  46.  
  47.     '/****************設置查詢SQL語句*******************************  
  48.     ''查詢顯示字段  
  49.     Public Property Let Fields(ByVal Value)  
  50.         List_Fields=Value  
  51.     End Property  
  52.     Public Property Get Fields()  
  53.         Fields=List_Fields  
  54.     End Property  
  55.     ''查詢表名  
  56.     Public Property Let TableName(ByVal Value)  
  57.         Table_Name=Value  
  58.     End Property  
  59.     Public Property Get TableName()  
  60.         TableName=Table_Name  
  61.     End Property  
  62.     ''查詢條件  
  63.     Public Property Let Condition(ByVal Value)  
  64.         Query_Where=Value  
  65.     End Property  
  66.     Public Property Get Condition()  
  67.         Condition=Query_Where  
  68.     End Property  
  69.     ''*****************排序部分********************************************  
  70.     ''Value 語不用寫上Order By 。如: [object].OrderBy="ID Desc,PostTime Asc"  
  71.     Public Property Let OrderBy(ByVal Value)  
  72.         OrderBy_SQL=Value  
  73.     End Property  
  74.     Public Property Get OrderBy()  
  75.         OrderBy=OrderBy_SQL  
  76.     End Property  
  77.     '/****************End******************************************  
  78.  
  79.     '/****************返回當前查詢結果的總頁數***********************  
  80.     Public Property Get PageCount()  
  81.         PageCount=Page_Count  
  82.     End Property  
  83.     Public Property Get RecordCount()  
  84.         RecordCount=Record_Count  
  85.     End Property  
  86.     Public Property Get NextPage()  
  87.         If Cur_Page<Page_Count Then  
  88.             NextPage=Cur_Page+1  
  89.         Else  
  90.             NextPage=Page_Count  
  91.         End If  
  92.     End Property  
  93.     Public Property Get PrePage()  
  94.         If Cur_Page>1 Then  
  95.             PrePage=Cur_Page-1  
  96.         Else  
  97.             PrePage=Cur_Page  
  98.         End If  
  99.     End Property  
  100.     '/****************End******************************************  
  101.  
  102.     '/****************設置一頁顯示的記錄數***************************  
  103.     Public Property Let PageSize(ByVal Value)  
  104.         If Not IsNumeric(Value) Or Value="" Then  
  105.             Value=10  
  106.         Else  
  107.             Value=Cint(Value)  
  108.         End If  
  109.         If Value<1 Then Value=10  
  110.         Page_Size=Value  
  111.     End Property  
  112.     Public Property Get PageSize()  
  113.         PageSize=Page_Size  
  114.     End Property  
  115.     ''設置當前的頁碼數**************************  
  116.     Public Property Let Page(ByVal Value)  
  117.         If Not IsNumeric(Value) Or Value="" Then  
  118.             Value=1  
  119.         Else  
  120.             Value=CLng(Value)  
  121.         End If  
  122.         If Value<1 Then Value=1  
  123.         Cur_Page=Value  
  124.     End Property  
  125.     Public Property Get Page()  
  126.         Page=Cur_Page  
  127.     End Property  
  128.     '/****************End******************************************  
  129.  
  130.     Private Sub Class_Initialize  
  131.     '初始化RecordSet對象  
  132.         Page_Size=10            '默認一頁為10條數據  
  133.         CurPage=1                   '默認當前為第一頁  
  134.         Record_Count=0  
  135.         Page_Count=0  
  136.     End Sub  
  137.  
  138.     Private Sub Class_Terminate  
  139.         Call CloseRecordSet  
  140.     End Sub  
  141.  
  142.     '/***關閉數據庫的連接*******  
  143.     Private Sub CloseRecordSet  
  144.         On Error Resume Next  
  145.         If IsObject(Rs) Then  
  146.             Rs.Close  
  147.             Set Rs=Nothing  
  148.         End If  
  149.         On Error Goto 0  
  150.     End Sub  
  151.  
  152.     '/**********執行查詢返回對應頁碼的數據***********************************************  
  153.     Public Function ExecuteBy(ByVal oTableName,ByVal oFields,ByVal oCondition,ByVal oOrderBy)  
  154.         Table_Name=oTableName  
  155.         List_Fields=oFields  
  156.         Query_Where=oCondtion  
  157.         OrderBy_SQL=oOrderBy  
  158.         Set ExecuteBy=Execute()  
  159.     End Function  
  160.     '查詢并返回當前CurPage的頁碼記錄  
  161.     Public Function Execute()  
  162.         Call CloseRecordSet  
  163.         On Error Resume Next  
  164.         Dim TSQL,TopMod,sWhere  
  165.         If Not IsObject(Connection) Or Table_Name="" Or OrderBy_SQL="" Then  
  166.             Set Execute=Nothing  
  167.             Record_Count=0  
  168.             Page_Count=0  
  169.             Exit Function  
  170.         End If  
  171.         If Trim(Query_Where)<>"" Then   
  172.             sWhere="Where "&Query_Where  
  173.         Else  
  174.             sWhere=""  
  175.         End If  
  176.         TSQL="Select Count(*) From ["&Table_Name&"] "&sWhere  
  177.         Record_Count=Connection.Execute(TSQL)(0)    '獲取記錄總數  
  178.         If Err Then  
  179.             Err.Clear  
  180.             Set Execute=Nothing  
  181.             Record_Count=0  
  182.             Page_Count=0  
  183.             Exit Function  
  184.         End If  
  185.         If Record_Count<1 Then  
  186.             Set Execute=Nothing  
  187.             Record_Count=0  
  188.             Page_Count=0  
  189.             Exit Function  
  190.         End If  
  191.         '取得頁的總數  
  192.         If Record_Count Mod Page_Size <>0 Then  
  193.             TopMod=Record_Count Mod Page_Size  
  194.             Page_Count=Fix(Record_Count/Page_Size)+1  
  195.             If Cur_Page<Page_Count Then  
  196.                 TopMod=Page_Size  
  197.             End If  
  198.         Else  
  199.             TopMod=Page_Size  
  200.             Page_Count=Fix(Record_Count/Page_Size)  
  201.         End If  
  202.         If Cur_Page>Page_Count Then Cur_Page=Page_Count  
  203.         If Cur_Page<1 Then Cur_Page=1  
  204.         If Trim(List_Fields)="" Then List_Fields="*"  
  205.         TSQL="Select * From (Select Top "&TopMod&" * From (Select Top "&(Cur_Page*Page_Size)&" "&List_Fields&" From ["&Table_Name&"] "&sWhere&" Order By "&OrderBy_SQL&") Order By "&TransformOrder(OrderBy_SQL)&")Order By "&OrderBy_SQL  
  206.         Set Rs=Connection.Execute(TSQL)  
  207.         If Err Then  
  208.             Err.Clear  
  209.             Set Execute=Nothing  
  210.             Record_Count=0  
  211.             Page_Count=0  
  212.             Exit Function  
  213.         End If  
  214.         Set Execute=Rs  
  215.     End Function  
  216.  
  217.     '轉換OrderBy的順序 ASC->DESC   DESC->ASC  
  218.     Private Function TransformOrder(ByVal Value)  
  219.         If Value="" Then  
  220.             TransformOrder=""  
  221.             Exit Function  
  222.         End If  
  223.         Dim OrderArray,i,Result,ByString,Fields,InPos  
  224.         OrderArray=Split(Value,",")   '分解每個字段值  
  225.         For i=0 To Ubound(OrderArray)  
  226.             If OrderArray(i)<>"" Then  
  227.                 InPos=InStrRev(Trim(OrderArray(i))," ")  '找出排序的順序  
  228.                 If InPos<1 Then  '如果找不到則是ASC排序  
  229.                     ByString="ASC"  
  230.                     Fields=OrderArray(i)+" "  
  231.                 Else  
  232.                     ByString=Trim(Mid(OrderArray(i),InPos+1))  
  233.                     Fields=Left(OrderArray(i),InPos)  
  234.                     If ByString<>"" Then  
  235.                         ByString=UCase(ByString)  
  236.                     Else  
  237.                         ByString="ASC"  
  238.                     End If  
  239.                 End If  
  240.                 ''轉換排序  
  241.                 If ByString="ASC" Then  
  242.                     ByString="DESC"  
  243.                 Else  
  244.                     ByString="ASC"  
  245.                 End If  
  246.                 Result=Result+Fields+ByString+","  
  247.             End If  
  248.         Next  
  249.         If Result<>"" Then Result=Left(Result,Len(Result)-1)  
  250.         TransformOrder=Result  
  251.     End Function  
  252. End Class  
  253.  
  254.  
  255. '示例代碼:  
  256. Sub Show_List  
  257.     Dim Page,PageRs  
  258.     Page=Request("Page")  
  259.     Dim MyPage  
  260.     Set MyPage=New PageClass  
  261.     MyPage.Conn=Conn  
  262.     MyPage.PageSize=20  
  263.     MyPage.Page=Page  
  264.     MyPage.TableName="table1"  
  265.     MyPage.Fields="*"  
  266.     MyPage.OrderBy="ID Asc"  
  267.     Set PageRs=MyPage.Execute  
  268.     'Set PageRs=MyPage.ExecuteBy("table1","*","","ID Asc")  
  269.     If PageRs Is Nothing Then Exit Sub  
  270.     Do Until PageRs.Eof  
  271.         Response.Write " <tr bgcolor=""#FDFDFD"" style=""cursor:hand"" onmouseover=""this.style.background='#F3F3F3'"" onmouseout=""this.style.background='#FDFDFD'"">"  
  272.         Response.Write "    <td height=""20""><div align=""center"">"&PageRs("ID")&"</div></td>"  
  273.         Response.Write "    <td>"&PageRs("aaaa")&"</td>"  
  274.         Response.Write "    <td><a href="""&PageRs("bbbb")&"""><font color='#000000'>"&PageRs("bbbb")&"</font></a></td>"  
  275.         Response.Write "    <td>"&PageRs("cccc")&"</td>"  
  276.         Response.Write "  </tr>"  
  277.         PageRs.MoveNext  
  278.     Loop  
  279.     PageRs.Close  
  280.     PageCount=MyPage.PageCount  
  281.     Page=MyPage.Page            '取得當前正確的頁碼數  
  282.     NextPage=MyPage.NextPage  
  283.     PrePage=MyPage.PrePage  
  284.     Set PageRs=Nothing  
  285.     Set MyPage=Nothing  
  286. End Sub  
  287. Show_List  
  288. %>  

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 久久精品电影 | 日韩精品一区二区三区中文在线 | 国产精品视频 | www.嫩草| 精品视频一区在线观看 | 日韩不卡一区二区三区 | 亚洲精品一区二区在线观看 | 亚洲一本 | 精精国产 | 亚洲毛片| 国产羞羞视频在线观看 | 在线观看免费黄视频 | av在线资源网 | 天堂欧美城网站网址 | 国产精品久久九九 | 久草视频网 | 国产精品爱久久久久久久 | 亚洲国产aⅴ成人精品无吗 成人午夜视频在线观看 | 一级免费毛片 | 老女肥熟av免费观看 | 亚洲国产一二区 | 色综合天天综合网国产成人综合天 | 美女主播精品视频一二三四 | 毛片在线视频 | 亚洲成人免费 | 天堂av中文在线 | 国产欧美日韩综合精品一区二区 | 国产精品久久久久久久久久小说 | 在线日本视频 | 久久精品一二三四 | 蜜桃传媒一区二区 | 国产精品不卡视频 | 国产精品免费一区二区三区四区 | 亚洲精品一区二区三区在线 | 亚洲一区中文字幕 | 中文字幕三区 | 欧美成人综合在线 | 一级黄色一级黄色 | 在线亚洲电影 | 精品国产乱码久久久久夜 | 国产精品区二区三区日本 |