asp的通用数据分页类(6)
'取得页的总数
If Record_Count Mod Page_Size <>0 Then
TopMod=Record_Count Mod Page_Size
Page_Count=Fix(Record_Count/Page_Size)+1
If Cur_Page<Page_Count Then
TopMod=Page_Size
End If
Else
TopMod=Page_Size
Page_Count=Fix(Record_Count/Page_Size)
End If
If Cur_Page>Page_Count Then Cur_Page=Page_Count
If Cur_Page<1 Then Cur_Page=1
If Trim(List_Fields)="" Then List_Fields="*"
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
Set Rs=Connection.Execute(TSQL)
If Err Then
Err.Clear
Set Execute=Nothing
Record_Count=0
Page_Count=0
Exit Function
End If
Set Execute=Rs
End Function
'转换OrderBy的顺序 ASC->DESC DESC->ASC
Private Function TransformOrder(ByVal Value)
If Value="" Then
TransformOrder=""
Exit Function
End If
内容版权声明:除非注明,否则皆为本站原创文章。