叶子的分页类

转自: http://goaler.xicp.net/ShowLog.asp?ID=492

Cls_ShowoPage.asp

<%
Class Cls_ShowoPage
Private Showo_PageSize,Showo_CurrPage
Private Showo_Conn,Showo_DbType,Showo_RecType,Showo_RecSql,Showo_RecTerm,Showo_CookieName
Private S_Order,Showo_JsUrl
Private Showo_Sql,Showo_Field,Showo_Table,Showo_Where,Showo_OrderBy,Showo_Id
Private Showo_RecCount,Showo_PageCount,ResultSet_Sql
Private Showo_Cm,Showo_WhereOther,Showo_Order,Showo_Size,Showo_Mm 'MSSQL用

'================================================================
' Class_Initialize 类的初始化
'================================================================
Private Sub Class_Initialize
Showo_PageSize=10 '设定每页记录条数的默认值为10
Showo_CurrPage=CheckNum(Trim(Request("Page")),1,-1) '获取当前面的值
Showo_Order=">" '默认排序
Showo_Size="MAX" '默认排序
Showo_WhereOther="" '默认条件
End Sub

'================================================================
' Conn 得到数据库连接对象
'================================================================
Public Property Let Conn(ByVal objConn)
Set Showo_Conn=objConn
End Property

'================================================================
' DbType 得到数据库类型
'================================================================
Public Property Let DbType(ByVal strDbType)
Showo_DbType=strDbType
End Property

'================================================================
' RecType 取记录总数方法(0执行count,1自写sql语句取,2固定值)
'================================================================
Public Property Let RecType(ByVal intRecType)
Showo_RecType=CheckNum(intRecType,0,2)
End Property

'================================================================
' RecSql '如果RecType=1则=取记录sql语句,如果是2=数值,等于0=""
'================================================================
Public Property Let RecSql(ByVal strRecSql)
Showo_RecSql=strRecSql
End Property

'================================================================
' RecTerm 搜索条件是否变化(0无变化,1有变化)
'================================================================
Public Property Let RecTerm(ByVal intRecTerm)
Showo_RecTerm=CheckNum(intRecTerm,0,2)
End Property

'================================================================
' CookieName 取得cookiename
'================================================================
Public Property Let CookieName(ByVal strCookieName)
Showo_CookieName=strCookieName
End Property

'================================================================
' Order 排序(0顺序,1降序)
'================================================================
Public Property Let Order(ByVal intOrder)
S_Order=CheckNum(intOrder,0,1)
If S_Order=1 Then
Showo_Order="<"
Showo_Size="MIN"
End If
End Property

'================================================================
' PageSize 设置每一页记录条数,默认10记录
'================================================================
Public Property Let PageSize(ByVal intPageSize)
Showo_PageSize=CheckNum(intPageSize,Showo_PageSize,-1)
End Property

'================================================================
' JsUrl 取得showo_page.js的路径
'================================================================
Public Property Let JsUrl(ByVal strJsUrl)
Showo_JsUrl=strJsUrl
End Property

'================================================================
' Sql 取得sql所需表字段条件排序,输入:字段,表,条件,排序,主ID
'================================================================
Public Property Let Sql(ByVal str_sql)
Showo_Sql=Split(str_sql,"$")
Showo_Field=Showo_Sql(0)
Showo_Table=Showo_Sql(1)
Showo_Where=Showo_Sql(2)
Showo_OrderBy=Showo_Sql(3)
Showo_Id=Showo_Sql(4)
If Len(Showo_Where)>=3 Then
Showo_WhereOther=" And "&Showo_Where
Showo_Where=" Where "&Showo_Where
End If
If Len(Showo_OrderBy)>3 Then Showo_OrderBy=" ORDER BY "&Showo_OrderBy
End Property

'================================================================
' GetRecCount 取得记录总数
'================================================================
Private Function GetRecCount()
Select Case Showo_RecType
Case 1
GetRecCount=Showo_Conn.execute(Showo_RecSql,0,1)(0)
Case 2
GetRecCount=CheckNum(Showo_RecSql,0,-1)
Case Else
GetRecCount=Showo_Conn.execute("SELECT Count("&Showo_Id&") FROM "&Showo_Table&" "&Showo_Where,0,1)(0)
End Select
End Function

'================================================================
' RecCount 修正记录总数
'================================================================
Public Property Get RecCount()
RecCount=Request.Cookies("ShowoPage")(Showo_CookieName)
RecCount=CheckNum(RecCount,0,-1)
Select Case Showo_RecTerm
Case 1
RecCount=GetRecCount()
Response.Cookies("ShowoPage")(Showo_CookieName)=RecCount
Case 2
RecCount=GetRecCount()
Case Else
If RecCount=0 Then
RecCount=GetRecCount()
Response.Cookies("ShowoPage")(Showo_CookieName)=RecCount
End If
End Select
End Property

'================================================================
' ResultSet 返回分页后的记录集
'================================================================
Public Property Get ResultSet()
ResultSet=Null
'记录总数
Showo_RecCount=RecCount()
'当前页
If Showo_RecCount>0 Then
'页数
If (Showo_RecCount mod Showo_PageSize)=0 Then
Showo_PageCount=Showo_RecCount\Showo_PageSize
Else
Showo_PageCount=Showo_RecCount\Showo_PageSize+1
End If
'当前页
Showo_CurrPage=CheckNum(Showo_CurrPage,1,Showo_PageCount)
Select Case Showo_DbType
Case "AC" 'ac数据库
Set Showo_Rs=Server.CreateObject ("adodb.RecordSet")
ResultSet_Sql="SELECT "&Showo_Field&" FROM "&Showo_Table&" "&Showo_Where&" "&Showo_OrderBy
Showo_Rs.Open ResultSet_Sql,Showo_Conn,1,1,&H0001
Showo_Rs.AbsolutePosition=(Showo_CurrPage-1)*Showo_PageSize+1
Case "MSSQL" 'sqlserver2000数据库
If Showo_CurrPage=1 Then
ResultSet_Sql="SELECT TOP "&Showo_PageSize&" "&Showo_Field&" FROM "&Showo_Table&Showo_Where&" "&Showo_OrderBy
Else
ResultSet_Sql="SELECT "&Showo_Size&"("&Showo_Id&") FROM (SELECT TOP "&(Showo_CurrPage-1)*Showo_PageSize&" "&Showo_Id&" FROM "&Showo_Table&Showo_Where&" "&Showo_OrderBy&") AS tmpTable"
Showo_Mm=Showo_Conn.execute(ResultSet_Sql,0,1)(0)
ResultSet_Sql="SELECT TOP "&Showo_PageSize&" "&Showo_Field&" FROM "&Showo_Table&" WHERE "&Showo_Id&Showo_Order&Showo_Mm&Showo_WhereOther&" "&Showo_OrderBy
End If
Set Showo_Rs=Showo_Conn.execute(ResultSet_Sql)
Case "MSSQL_SP" 'sqlserver2000数据库存储过程版
Set Showo_Rs=server.CreateObject("Adodb.RecordSet")
Set Showo_Cm=Server.CreateObject("Adodb.Command")
Showo_Cm.CommandType=4
Showo_Cm.ActiveConnection=Showo_Conn
Showo_Cm.CommandText="SP_ShowoPage"
Showo_Cm.parameters(1)=Showo_CurrPage
Showo_Cm.parameters(2)=Showo_PageSize
Showo_Cm.parameters(3)=Showo_Field
Showo_Cm.parameters(4)=Showo_Table
Showo_Cm.parameters(5)=Showo_Where
Showo_Cm.parameters(6)=Showo_WhereOther
Showo_Cm.parameters(7)=Showo_OrderBy
Showo_Cm.parameters(8)=Showo_Id
Showo_Cm.parameters(9)=Showo_Size
Showo_Cm.parameters(10)=Showo_Order
Showo_Rs.CursorLocation=1
Showo_Rs.LockType=1
Showo_Rs.Open Showo_Cm
Case Else '其他情况按最原始的方法处理
Set Showo_Rs = Server.CreateObject ("adodb.RecordSet")
ResultSet_Sql="SELECT "&Showo_Field&" FROM "&Showo_Table&" "&Showo_Where&" "&Showo_OrderBy
Showo_Rs.Open ResultSet_Sql,Showo_Conn,1,1,&H0001
Showo_Rs.AbsolutePosition=(Showo_CurrPage-1)*Showo_PageSize+1
End Select
ResultSet=Showo_Rs.GetRows(Showo_PageSize)
Showo_Rs.close
Set Showo_Rs=Nothing
End If
End Property

'================================================================
' 输入:检查字段,开始数字(默认数字),结束数字(为-1则不检查大小)
'================================================================
Private Function CheckNum(ByVal strStr,ByVal intStartNum,ByVal intEndNum)
CheckNum=intStartNum
If IsNumeric(strStr) Then CheckNum=Clng(strStr)
If intEndNum>-1Then
If CheckNum<intStartNum Then CheckNum=intStartNum
If CheckNum>intEndNum Then CheckNum=intEndNum
End If
End Function

'================================================================
' Class_Terminate 类注销
'================================================================
Private Sub Class_Terminate()
If IsObject(Showo_Conn) Then
Showo_Conn.Close
Set Showo_Conn=Nothing
End If
End Sub

'================================================================
' 上下页部分
'================================================================
Public Sub ShowPage()%>
<Script Language="JavaScript" type="text/JavaScript" src="<%=Showo_JsUrl%>showo_page.js"></Script>
<Script Language="JavaScript">
ShowoPage("<table style='BORDER-COLLAPSE: collapse' borderColor='#111111' height='10' cellSpacing='0' cellPadding='0' width='95%' border='0'><tr><td vAlign='bottom' style='font-family: Verdana,宋体; font-size: 11.5px; line-height: 15px'>","</td></tr></table>","页次:<font color='red'>","</font>/","","&nbsp;","&nbsp;每页<font color='red'>","</font>&nbsp;","&nbsp;共计:<font color='red'>","</font></td><td vAlign='bottom' align='right' style='font-family: Verdana,宋体; font-size: 11.5px; line-height: 15px'>","<font face=webdings>9</font>","<font face=webdings>7</font>","<font face=webdings>8</font>","<font face=webdings>:</font>","&nbsp;&nbsp;跳转:","<font color='orange'>[","]</font>","","","<font color='red'>","</font>","","",<%=RecCount()%>,<%=Showo_PageSize%>,2)
</Script>
<%End Sub

End Class%>

pageAC.asp

<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="Cls_ShowoPage.asp"-->
<%
On Error Resume Next
DIM startime,endtime
'统计执行时间
startime=timer()
'连接数据库
DIM Db,Conn,Rs
Db = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("db/IP.mdb")
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.open Db
'-----------------------------------------------------------------------------------------------
%>
<html>
<head>
<title>叶子ASP分页类-access调用示范</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
<!--
table { font-size: 12px}
a { font-size: 12px; color: #000000; text-decoration: none}
-->
</style>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<table width="760" border="0" cellspacing="2" cellpadding="2" align="center" height="30">
<tr>
<td>&nbsp;</td>
</tr>
</table>
<table width="760" border="1" cellspacing="0" cellpadding="4" align="center" bordercolordark="#FFFFFF" bordercolorlight="#CCCCCC">
<tr align="center">
<td width="20">ID</td>
<td>标题</td>
<td>内容(显示前20个字)</td>
<td>时间</td>
</tr>
<%
Dim ors
Set ors=new Cls_ShowoPage'创建对象
With ors
.Conn=conn'得到数据库连接对象
.DbType="AC"
'数据库类型,AC为access,MSSQL为sqlserver2000,MSSQL_SP为存储过程版,MYSQL为mysql,PGSQL为PostGreSql
.RecType=0
'取记录总数方法(0执行count,1自写sql语句取,2固定值)
.RecSql=0
'如果RecType=1则=取记录sql语句,如果是2=数值,等于0=""
.RecTerm=0
'取从记录条件是否有变化(0无变化,1有变化,2不设置cookies也就是及时统计,适用于搜索时候)
.CookieName="recac"'如果RecTerm=2,cookiesname="",否则写cookiesname
.Order=0'排序(0顺序1降序),注意要和下面sql里面主键ID的排序对应
.PageSize=13'每页记录条数
.JsUrl=""'showo_page.js的路径
.Sql="MID,ip2,country,city$dv_address$$$MID" '字段,表,条件(不需要where),排序(不需要需要ORDER BY),主键ID
End With

iRecCount=ors.RecCount()'记录总数
iRs=ors.ResultSet()'返回ResultSet
If iRecCount<1 Then%>
<tr bgcolor="">
<td >暂无记录</td>
</tr>
<%
Else
For i=0 To Ubound(iRs,2)%>
<tr bgcolor="#FFFFFF">
<td><%=iRs(0,i)%></td>
<td><%=iRs(1,i)%></td>
<td><%=left(iRs(2,i),20)%></td>
<td><%=iRs(3,i)%></td>
</tr><%
Next
End If
%>
</table>
<table width="760" border="0" cellspacing="2" cellpadding="2" align="center">
<tr>
<td>
<%ors.ShowPage()%>
</td>
</tr>
</table>
<table width="760" border="0" align="center" cellpadding="2" cellspacing="2">
<tr>
<td align="center">
<%endtime=timer()%>
本页面执行时间:<%=FormatNumber((endtime-startime)*1000,3)%>毫秒</td>
</tr>
</table>
</body>
</html>
<%
iRs=NULL
ors=NULL
Set ors=NoThing
%>

pageMSSQL.asp

<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="Cls_ShowoPage.asp"-->
<%
On Error Resume Next
DIM startime,endtime
'统计执行时间
startime=timer()
'连接数据库
DIM Db,Conn,Rs
strSQLServerName = "(local)" '服务器名称或地址
strSQLDBUserName = "sa" '数据库帐号
strSQLDBPassword = "19811004" '数据库密码
strSQLDBName = "showotempPage" '数据库名称
Set Conn = Server.CreateObject("ADODB.Connection")
Db = "Provider=SQLOLEDB.1;Persist Security Info=False;Server=" & strSQLServerName & ";User ID=" & strSQLDBUserName & ";Password=" & strSQLDBPassword & ";Database=" & strSQLDBName & ";"
Conn.open Db
'-----------------------------------------------------------------------------------------------
%>
<html>
<head>
<title>叶子ASP分页类-mssql调用示范</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
<!--
table { font-size: 12px}
a { font-size: 12px; color: #000000; text-decoration: none}
-->
</style>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<table width="760" border="0" cellspacing="2" cellpadding="2" align="center" height="30">
<tr>
<td>&nbsp;</td>
</tr>
</table>
<table width="760" border="1" cellspacing="0" cellpadding="4" align="center" bordercolordark="#FFFFFF" bordercolorlight="#CCCCCC">
<tr align="center">
<td width="20">ID</td>
<td>标题</td>
<td>内容(显示前20个字)</td>
<td>时间</td>
</tr>
<%
Dim ors
Set ors=new Cls_ShowoPage'创建对象
With ors
.Conn=conn'得到数据库连接对象
.DbType="MSSQL"
'数据库类型,AC为access,MSSQL为sqlserver2000,MSSQL_SP为存储过程版,MYSQL为mysql,PGSQL为PostgreSql
.RecType=0
'取记录总数方法(0执行count,1自写sql语句取,2固定值)
.RecSql=0
'如果RecType=1则=取记录sql语句,如果是2=数值,等于0=""
.RecTerm=0
'取从记录条件是否有变化(0无变化,1有变化,2不设置cookies也就是及时统计,适用于搜索时候)
.CookieName="recsql"'如果RecTerm=2,cookiesname="",否则写cookiesname
.Order=0'排序(0顺序1降序),注意要和下面sql里面主键ID的排序对应
.PageSize=13'每页记录条数
.JsUrl=""'showo_page.js的路径
.Sql="MID,ip2,country,city$dv_address$$$MID" '字段,表,条件(不需要where),排序(不需要ORDER BY),主键ID
End With
iRecCount=ors.RecCount() '记录总数
iRs=ors.ResultSet() '返回ResultSet
If iRecCount<1 Then%>
<tr bgcolor="">
<td >暂无记录</td>
</tr>
<%
Else
For i=0 To Ubound(iRs,2)%>
<tr bgcolor="#FFFFFF">
<td><%=iRs(0,i)%></td>
<td><%=iRs(1,i)%></td>
<td><%=left(iRs(2,i),20)%></td>
<td><%=iRs(3,i)%></td>
</tr><%
Next
End If
%>
</table>
<table width="760" border="0" cellspacing="2" cellpadding="2" align="center">
<tr>
<td>
<%ors.ShowPage()%>
</td>
</tr>
</table>
<table width="760" border="0" align="center" cellpadding="2" cellspacing="2">
<tr>
<td align="center">
<%endtime=timer()%>
本页面执行时间:<%=FormatNumber((endtime-startime)*1000,3)%>毫秒</td>
</tr>
</table>
</body>
</html>
<%
iRs=NULL
ors=NULL
Set ors=NoThing
%>

pageMSSQL_SP.asp

<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="Cls_ShowoPage.asp"-->
<%
On Error Resume Next
DIM startime,endtime
'统计执行时间
startime=timer()
'连接数据库
DIM Db,Conn,Rs
strSQLServerName = "(local)" '服务器名称或地址
strSQLDBUserName = "sa" '数据库帐号
strSQLDBPassword = "19811004" '数据库密码
strSQLDBName = "showotempPage" '数据库名称
Set Conn = Server.CreateObject("ADODB.Connection")
Db = "Provider=SQLOLEDB.1;Persist Security Info=False;Server=" & strSQLServerName & ";User ID=" & strSQLDBUserName & ";Password=" & strSQLDBPassword & ";Database=" & strSQLDBName & ";"
Conn.open Db
'-----------------------------------------------------------------------------------------------
%>
<html>
<head>
<title>叶子ASP分页类-mssql存储过程调用示范</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
<!--
table { font-size: 12px}
a { font-size: 12px; color: #000000; text-decoration: none}
-->
</style>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<table width="760" border="0" cellspacing="2" cellpadding="2" align="center" height="30">
<tr>
<td>&nbsp;</td>
</tr>
</table>
<table width="760" border="1" cellspacing="0" cellpadding="4" align="center" bordercolordark="#FFFFFF" bordercolorlight="#CCCCCC">
<tr align="center">
<td width="20">ID</td>
<td>标题</td>
<td>内容(显示前20个字)</td>
<td>时间</td>
</tr>
<%
Dim ors
Set ors=new Cls_ShowoPage'创建对象
With ors
.Conn=conn'得到数据库连接对象
.DbType="MSSQL_SP"
'数据库类型,AC为access,MSSQL为sqlserver2000,MSSQL_SP为存储过程版,MYSQL为mysql,PGSQL为PostgreSql
.RecType=0
'取记录总数方法(0执行count,1自写sql语句取,2固定值)
.RecSql=0
'如果RecType=1则=取记录sql语句,如果是2=数值,等于0=""
.RecTerm=0
'取从记录条件是否有变化(0无变化,1有变化,2不设置cookies也就是及时统计,适用于搜索时候)
.CookieName="recsql_sp"'如果RecTerm=2,cookiesname="",否则写cookiesname
.Order=0'排序(0顺序1降序),注意要和下面sql里面主键ID的排序对应
.PageSize=13'每页记录条数
.JsUrl=""'showo_page.js的路径
.Sql="MID,ip2,country,city$dv_address$$$MID" '字段,表,条件(不需要where),排序(不需要需要ORDER BY),主键ID
End With
iRecCount=ors.RecCount() '记录总数
iRs=ors.ResultSet() '返回ResultSet
If iRecCount<1 Then%>
<tr bgcolor="">
<td >暂无记录</td>
</tr>
<%
Else
For i=0 To Ubound(iRs,2)%>
<tr bgcolor="#FFFFFF">
<td><%=iRs(0,i)%></td>
<td><%=iRs(1,i)%></td>
<td><%=left(iRs(2,i),20)%></td>
<td><%=iRs(3,i)%></td>
</tr><%
Next
End If
%>
</table>
<table width="760" border="0" cellspacing="2" cellpadding="2" align="center">
<tr>
<td>
<%ors.ShowPage()%>
</td>
</tr>
</table>
<table width="760" border="0" align="center" cellpadding="2" cellspacing="2">
<tr>
<td align="center">
<%endtime=timer()%>
本页面执行时间:<%=FormatNumber((endtime-startime)*1000,3)%>毫秒</td>
</tr>
</table>
</body>
</html>
<%
iRs=NULL
ors=NULL
Set ors=NoThing
%>

showo_page.js

/*=================================================================
*名称:叶子js分页样式
*Description:js分页样式,显示上一页下一页的翻页结果
*=================================================================
/

var url,CurrPage,re,CurrentPage,iurl,FirstPageUrl,PrevPageUrl,NextPageUrl,LastPageUrl,PageCount,prevpage,nextpage,PageStart,PageEnd,i,ipage;
url=""+document.location;
if (url.indexOf("Page=")==-1) {
CurrPage=1;
}
else {
re=/(\S.*)(Page=\d*)(\S.*|\S*)/g;
CurrentPage=url.replace(re,"$2");
CurrentPage=CurrentPage.replace("Page=","");
//re=/(?:\S{1,}Page=|\D.*)/g;
//CurrentPage=url.replace(re,"");
url=url.replace("&Page="+CurrentPage,"");
url=url.replace("Page="+CurrentPage+"&","");
url=url.replace("Page="+CurrentPage,"");
}
url+=(url.indexOf("?")==-1)?"?":"&";
url=url.replace("?&","?");
url=url.replace("&&","&");
function FromatPage(str,StartNum,EndNum) {
str+="";
if (str.length>=1) {
mynum=parseInt(str,10);
if (isNaN(mynum)) {
mynum=StartNum;
}
else {
if (EndNum>-1) {
mynum=(mynum<StartNum)?StartNum:mynum;
mynum=(mynum>EndNum)?EndNum:mynum;
}
else {
mynum=(mynum<StartNum)?StartNum:mynum;
}
}
}
else {
mynum=StartNum;
}
return (mynum);
}
function CheckPage(iPageCount) {
url+='&Page=';
url=url.replace("?&","?");
url=url.replace("&&","&");
ipage=showoPage.value;
location.href(url+FromatPage(ipage,1,iPageCount));
}
function ShowoPage(Tabstart,Tabend,CurrPageFont1,CurrPageFont2,PageCountFont1,PageCountFont2,PrePageFont1,PrePageFont2,RecCountFont1,RecCountFont2,FirstFont,PrevFont,NextFont,LastFont,Jump,PageNumFont1,PageNumFont2,PageNumFont3,PageNumFont4,LinkFont1,LinkFont2,LinkFont3,LinkFont4,iRecCount,iRecPerPage,iPageNum) {
RecCount=FromatPage(iRecCount,0,-1);
RecPerPage=FromatPage(iRecPerPage,1,-1);
PageNum=FromatPage(iPageNum,0,-1);
PageCount=(RecCount%RecPerPage==0)?(RecCount/RecPerPage):(FromatPage((RecCount/RecPerPage),0,RecCount)+1);
CurrPage=(PageCount>0)?(FromatPage(CurrentPage,1,PageCount)):(FromatPage(CurrentPage,0,PageCount));
prevpage=FromatPage((CurrPage-1),1,PageCount);
nextpage=FromatPage((CurrPage+1),1,PageCount);
if (CurrPage<=1&&PageCount<=1) {
FirstPageUrl="&nbsp;"+LinkFont3+FirstFont+LinkFont4+"&nbsp;";
PrevPageUrl="&nbsp;"+LinkFont3+PrevFont+LinkFont4+"&nbsp;";
NextPageUrl="&nbsp;"+LinkFont3+NextFont+LinkFont4+"&nbsp;";
LastPageUrl="&nbsp;"+LinkFont3+LastFont+LinkFont4+"&nbsp;";
}
else if (CurrPage==1&&PageCount>1) {
FirstPageUrl="&nbsp;"+LinkFont3+FirstFont+LinkFont4+"&nbsp;";
PrevPageUrl="&nbsp;"+LinkFont3+PrevFont+LinkFont4+"&nbsp;";
NextPageUrl="&nbsp;<A href=\""+url+"Page="+nextpage+"\">"+LinkFont1+NextFont+LinkFont2+"</A>&nbsp;";
LastPageUrl="&nbsp;<A href=\""+url+"Page="+PageCount+"\">"+LinkFont1+LastFont+LinkFont2+"</A>&nbsp;";
}
else if (CurrPage==PageCount) {
FirstPageUrl="&nbsp;<A href=\""+url+"Page=1\">"+LinkFont1+FirstFont+LinkFont2+"</A>&nbsp;";
PrevPageUrl="&nbsp;<A href=\""+url+"Page="+prevpage+"\">"+LinkFont1+PrevFont+LinkFont2+"</A>&nbsp;";
NextPageUrl="&nbsp;"+LinkFont3+NextFont+LinkFont4+"&nbsp;";
LastPageUrl="&nbsp;"+LinkFont3+LastFont+LinkFont4+"&nbsp;";
}
else {
FirstPageUrl="&nbsp;<A href=\""+url+"Page=1\">"+LinkFont1+FirstFont+LinkFont2+"</A>&nbsp;";
PrevPageUrl="&nbsp;<A href=\""+url+"Page="+prevpage+"\">"+LinkFont1+PrevFont+LinkFont2+"</A>&nbsp;";
NextPageUrl="&nbsp;<A href=\""+url+"Page="+nextpage+"\">"+LinkFont1+NextFont+LinkFont2+"</A>&nbsp;";
LastPageUrl="&nbsp;<A href=\""+url+"Page="+PageCount+"\">"+LinkFont1+LastFont+LinkFont2+"</A>&nbsp;";
}
PageStart=FromatPage((CurrPage-PageNum),1,PageCount);
PageEnd=FromatPage((CurrPage+PageNum),1,PageCount);
document.write (CurrPageFont1+CurrPage+CurrPageFont2+PageCountFont1+PageCount+PageCountFont2+PrePageFont1);
document.write (RecPerPage+PrePageFont2+RecCountFont1+RecCount+RecCountFont2+FirstPageUrl+PrevPageUrl);
if (CurrPage>=1) {
for (i=PageStart;i<=PageEnd;i++) {
if (i!=CurrPage) {
document.write ("&nbsp;<A href=\""+url+"Page="+i+"\">"+PageNumFont1+i+PageNumFont2+"</A>&nbsp;");
}
else {
document.write ("&nbsp;"+PageNumFont3+i+PageNumFont4+"&nbsp;");
}
}
}
document.write (NextPageUrl+LastPageUrl+Jump);
document.write ("<INPUT type=\"text\" id=\"showoPage\" size=\"5\" maxlength=\"10\" onkeydown=\"if (event.keyCode==13) CheckPage("+PageCount+")\"><INPUT type=\"button\" value=\"Go\" onClick=\"CheckPage("+PageCount+")\">"+Tabend);
}

mssql_sp.sql

CREATE PROCEDURE SP_ShowoPage
@Showo_CurrPageINT,
@Showo_PageSizeINT,
@Showo_FieldVARCHAR(800),
@Showo_TableVARCHAR(50),
@Showo_WhereVARCHAR(800),
@Showo_WhereOtherVARCHAR(800),
@Showo_OrderByVARCHAR(800),
@Showo_IdVARCHAR(50),
@Showo_SizeVARCHAR(3),
@Showo_OrderVARCHAR(5)

AS

SET NOCOUNT ON
DECLARE @SQL NVARCHAR(4000)

IF @Showo_CurrPage=1
SET @SQL='SELECT TOP '+CAST(@Showo_PageSize AS VARCHAR)+' '+@Showo_Field+' FROM '+@Showo_Table+@Showo_Where+' '+@Showo_OrderBy
ELSE
SET @SQL='SELECT TOP '+CAST(@Showo_PageSize AS VARCHAR)+' '+@Showo_Field+' FROM '+@Showo_Table+' WHERE '+@Showo_Id+@Showo_Order+'(SELECT '+@Showo_Size+'('+@Showo_Id+') FROM (SELECT TOP '+CAST(@Showo_PageSize*(@Showo_CurrPage-1) AS VARCHAR)+' '+@Showo_Id+' FROM '+@Showo_Table+@Showo_Where+' '+@Showo_OrderBy+') AS tmpTable) '+@Showo_WhereOther+' '+@Showo_OrderBy

EXEC(@SQL)
GO

你可能感兴趣的:(sql,mysql,SQL Server,asp.net,asp)