名稱: 葉子asp分頁類
Name: ShowoPage(vbs class)
RCSfile: ReadMe.txt
Revision: 0.12.20051114.f
Author: Yehe(葉子)
Released: 2005-11-14 09:40:13
Descript: ASP分頁類,支持access/mssql/mysql/sqlite
Contact: QQ:311673 MSN:
[email protected] GT:
[email protected] WebSite: http://www.yehe.org http://www.showo.com
------------------------------------------------
Licenses:
本程序遵循GPL協議.
協議原文地址:http://www.gnu.org/licenses/licenses.cn.html#GPL
------------------------------------------------
Thanks:
可洛: 感謝mssql分頁核心部分
Arbiter: 感謝部分分頁思路
才子: 感謝推廣
foxty: 感謝分頁思路
------------------------------------------------
Install:
1.具體調用方法可以看demo的asp文檔.
2.mssql存儲過程版的請先執行sp_Util_Page.sql文件添加存儲過程.
3.sp調用方法:
exec sp_Util_Page 440000,4,10,''MID'',''MID,ip1,ip2,country,city'',''tbTempPage'',''1=1'',''mid asc''
記錄條數(已有值:序外部賦值,0執行count),當前頁數,每頁記錄數,主鍵,字段,表,條件(不需要where),排序(不需要order by,需要asc和desc字符)
如果不按主鍵排序,則排序賦值裡面不能出現主鍵字符.
------------------------------------------------
Release:
0.12
1.取text字段類型bug修正
2.存儲過程bug修正
3.代碼修正
0.11
1.存儲過程加了非主鍵排序下的分頁
2.去掉了mssql的非存儲過程版分頁
0.10:
1.條件簡化
2.存儲過程優化
0.09:
1.排序判斷部分優化
0.08:
1.vbs bug修正
0.07:
1.bug修正,包括vbs類和js
0.06Beta:
1.js浏覽器兼容優化
2.類幾個函數的bug修正
0.05Beta:
1.全面代碼優化,mysql/sqlite支持
2.參數輸入方式修改
0.04Beta:
1.做到調用代碼一樣適應多種數據庫集成分頁
2.js去掉了表單,支持靜態提交
3.加上了存儲過程
0.03Beta:
1.公開發布的顯示為0.02,其實為0.03,分為ac版類,mssql版類發布
2.js的bug修正
3.寫成了類,進一步方便調用
0.02Beta:
1.加上對mssql的支持
2.封裝成了函數版,方便調用
3.js文件的優化
0.01Beta:
1.沒有寫成函數,只是找到了比較快的ac分頁方法
2.分頁樣式用js顯示
------------------------------------------------
File:
db/IP.mdb access測試數據庫
db/IP mssql備份測試數據庫
Cls_vbsPage.asp 分頁類
Cls_jsPage.js js分頁樣式
sp_Util_Page.sql mssql存儲過程
demoAC.asp ac分頁調用示范
demoMSSQL.asp mssql調用示范
demoMSSQL_SP.asp mssql存儲過程調用示范
Cls_vbsPage.asp
<%
Class Cls_vbsPage
Private oConn ''連接對象
Private iPagesize ''每頁記錄數
Private sPageName ''地址欄頁數參數名
Private sDbType
''數據庫類型,AC為access,MSSQL為SQL SERVER2000存儲過程版,MYSQL為mysql,PGSQL為PostGreSql
Private iRecType ''記錄總數(>0為另外取值再賦予或者固定值,0執行count設置存cookies,-1執行count不設置cookies)
Private sJsUrl ''Cls_jsPage.js的路徑
Private sField ''字段名
Private sTable ''表名
Private sCondition ''條件,不需要where
Private sOrderBy ''排序,不需要order by,需要asc或者desc
Private sPkey ''主鍵,必寫
Private iRecCount
''================================================================
'' Class_Initialize 類的初始化
''================================================================
Private Sub Class_Initialize
iPageSize=10
sPageName="Page"
sDbType="AC"
iRecType=0
sJsUrl=""
sField=" * "
End Sub
''================================================================
'' Conn 得到數據庫連接對象
''================================================================
Public Property Set Conn(ByRef Value)
Set oConn=Value
End Property
''================================================================
'' PageSize 設置每一頁記錄條數,默認10記錄
''================================================================
Public Property Let PageSize(ByVal intPageSize)
iPageSize=CheckNum(intPageSize,0,0,iPageSize,0)
End Property
''================================================================
'' PageName 地址欄頁數參數名
''================================================================
Public Property Let PageName(ByVal strPageName)
sPageName=IIf(Len(strPageName)<1,sPageName,strPageName)
End Property
''================================================================
'' DbType 得到數據庫類型
''================================================================
Public Property Let DbType(ByVal strDbType)
sDbType=UCase(IIf(Len(strDbType)<1,sDbType,strDbType))
End Property
''================================================================
'' RecType 取記錄總數(>0為賦值或者固定值,0執行count設置存cookies,-1執行count不設置cookies適用於搜索)
''================================================================
Public Property Let RecType(ByVal intRecType)
iRecType=CheckNum(intRecType,0,0,iRecType,0)
End Property
''================================================================
'' JsUrl 取得Cls_jsPage.js的路徑
''================================================================
Public Property Let JsUrl(ByVal strJsUrl)
sJsUrl=strJsUrl
End Property
''================================================================
'' Pkey 取得主鍵
''================================================================
Public Property Let Pkey(ByVal strPkey)
sPkey=strPkey
End Property
''================================================================
'' Field 取得字段名
''================================================================
Public Property Let Field(ByVal strField)
sField=IIf(Len(strField)<1,sField,strField)
End Property
''================================================================
'' Table 取得表名
''================================================================
Public Property Let Table(ByVal strTable)
sTable=strTable
End Property
''================================================================
'' Condition 取得條件
''================================================================
Public Property Let Condition(ByVal strCondition)
s=strCondition
sCondition=IIf(Len(s)>2," WHERE "&s,"")
End Property
''================================================================
'' OrderBy 取得排序
''================================================================
Public Property Let OrderBy(ByVal strOrderBy)
s=strOrderBy
sOrderBy=IIf(Len(s)>4," ORDER BY "&s,"")
End Property
''================================================================
'' RecCount 修正記錄總數
''================================================================
Public Property Get RecCount()
If iRecType>0 Then
i=iRecType
Elseif iRecType=0 Then
i=CheckNum(Request.Cookies("ShowoPage")(sPageName),1,0,0,0)
s=Trim(Request.Cookies("ShowoPage")("sCond"))
IF i=0 OR sCondition<>s Then
i=oConn.Execute("SELECT COUNT("&sPkey&") FROM "&sTable&" "&sCondition,0,1)(0)
Response.Cookies("ShowoPage")(sPageName)=i
Response.Cookies("ShowoPage")("sCond")=sCondition
End If
Else
i=oConn.Execute("SELECT COUNT("&sPkey&") FROM "&sTable&" "&sCondition,0,1)(0)
End If
iRecCount=i
RecCount=i
End Property
''================================================================
'' ResultSet 返回分頁後的記錄集
''================================================================
Public Property Get ResultSet()
s=Null
''記錄總數
i=iRecCount
''當前頁
If i>0 Then
iPageCount=Abs(Int(-Abs(i/iPageSize)))''頁數
iPageCurr=CheckNum(Request.QueryString(sPageName),1,1,1,iPageCount)''當前頁
Select Case sDbType
Case "MSSQL" ''sqlserver2000數據庫存儲過程版
Set Rs=server.CreateObject("Adodb.RecordSet")
Set Cm=Server.CreateObject("Adodb.Command")
Cm.CommandType=4
Cm.ActiveConnection=oConn
Cm.CommandText="sp_Util_Page"
Cm.parameters(1)=i
Cm.parameters(2)=iPageCurr
Cm.parameters(3)=iPageSize
Cm.parameters(4)=sPkey
Cm.parameters(5)=sField
Cm.parameters(6)=sTable
Cm.parameters(7)=Replace(sCondition," WHERE ","")
Cm.parameters(8)=Replace(sOrderBy," ORDER BY ","")
Rs.CursorLocation=3
Rs.LockType=1
Rs.Open Cm
Case "MYSQL" ''MYSQL數據庫
ResultSet_Sql="SELECT "&sField&" FROM "&sTable&" "&sCondition&" "&sOrderBy&" LIMIT "&(iPageCurr-1)*iPageSize&","&iPageSize
Set Rs=oConn.Execute(ResultSet_Sql)
Case Else ''其他情況按最原始的方法處理(AC同理)
Set Rs = Server.CreateObject ("Adodb.RecordSet")
ResultSet_Sql="SELECT "&sField&" FROM "&sTable&" "&sCondition&" "&sOrderBy
Rs.Open ResultSet_Sql,oConn,1,1,&H0001
Rs.AbsolutePosition=(iPageCurr-1)*iPageSize+1
End Select
s=Rs.GetRows(iPageSize)
Rs.close
Set Rs=Nothing
End If
ResultSet=s
End Property
''================================================================
'' Class_Terminate 類注銷
''================================================================
Private Sub Class_Terminate()
If IsObject(oConn) Then oConn.Close:Set oConn=Nothing
End Sub
''================================================================
'' 輸入:檢查字符,是否有最小值,是否有最大值,最小值(默認數字),最大值
''================================================================
Private Function CheckNum(ByVal strStr,ByVal blnMin,ByVal blnMax,ByVal intMin,ByVal intMax)
Dim i,s,iMi,iMa
s=Left(Trim(""&strStr),32):iMi=intMin:iMa=intMax
If IsNumeric(s) Then
i=CDbl(s)
i=IIf(blnMin=1 And i<iMi,iMi,i)
i=IIf(blnMax=1 And i>iMa,iMa,i)
Else
i=iMi
End If
CheckNum=i
End Function
''================================================================
'' 輸入:簡化條件判斷
''================================================================
Private Function IIf(ByVal blnBool,ByVal strStr1,ByVal strStr2)
Dim s
If blnBool Then
s=strStr1
Else
s=strStr2
End If
IIf=s
End Function
''================================================================
'' 上下頁部分
''================================================================
Public Sub ShowPage()%>
<Script Language="JavaScript" type="text/JavaScript" src="<%=sJsUrl%>Cls_jsPage.js"></Script>
<Script Language="JavaScript" type="text/JavaScript">
var s= new Cls_jsPage(<%=iRecCount%>,<%=iPageSize%>,3,"s");
s.setPageSE("<%=sPageName%>=","");
s.setPageInput("<%=sPageName%>");
s.setUrl("");
s.setPageFrist("首頁","<<");
s.setPagePrev("上頁","<");
s.setPageNext("下頁",">");
s.setPageLast("尾頁",">>");
s.setPageText("[1]","第1頁");
s.setPageTextF(" {$PageTextF} "," {$PageTextF} ");
s.setPageSelect("1","第1頁");
s.setPageCss("","","");
s.setHtml("共{$RecCount}記錄 頁次{$Page}/{$PageCount} 每頁{$PageSize}條 {$PageFrist} {$PagePrev} {$PageText} {$PageNext} {$PageLast} {$PageInput} {$PageSelect}");
s.Write();
</Script>
<%End Sub
End Class%>
Cls_jsPage.js
/**
*=================================================================
*Name: 葉子js分頁樣式(ShowoPage Style With JS)
*RCSfile: Cls_jsPage.js
*Revision: 0.09
*Author: Yehe(葉子)
*Released: 2005-05-12 23:00:15
*Description: js分頁樣式,顯示上一頁下一頁的翻頁結果
*Contact: QQ:311673,MSN:
[email protected] *WebSite: http://www.yehe.org,http://www.showo.com
*=================================================================
*/
function Cls_jsPage(iRecCount,iPageSize,iPageNum,sName){
this.iRC=this.FormatNum(iRecCount,1,0,0,0);//總記錄條數
this.iPS=this.FormatNum(iPageSize,1,0,1,0);//每頁記錄數目
this.iPN=this.FormatNum(iPageNum,0,0,0,0);//顯示的前後頁數,0為顯示所有,負數為這麼多頁面一個跳轉
this.sN=sName;//實例對象名
this.sTPage="{$Page}";//頁數
this.sTPageCount="{$PageCount}";//總頁數
this.sTRecCount="{$RecCount}";//總記錄數
this.sTPageSize="{$PageSize}";//每頁記錄數
this.sTPageFrist="{$PageFrist}";//首頁
this.sTPagePrev="{$PagePrev}";//上頁
this.sTPageNext="{$PageNext}";//下頁
this.sTPageLast="{$PageLast}";//尾頁
this.sTPageText="{$PageText}";//數字跳轉
this.sTPageTextF="{$PageTextF}";//數字跳轉框架
this.sTPageInput="{$PageInput}";//輸入框跳轉
this.sTPageSelect="{$PageSelect}";//下拉菜單跳轉
this.sTPageNum="1";//數字頁數
this.iPC=this.getPageCount();//得到頁數
}
//輸入 頁數開始值,結尾值
Cls_jsPage.prototype.setPageSE=function(sPageStart,sPageEnd){
var sPS=sPageStart,sPE=sPageEnd;
this.sPS=(sPS.length>0)?sPS:"Page=";
this.sPE=(sPE.length>0)?sPE:"";
}
//輸入 網址
Cls_jsPage.prototype.setUrl=function(sUrl){
var s=sUrl;
this.Url=(s.length>0)?s:""+document.location;
}
//輸入 輸入框&下拉框name值
Cls_jsPage.prototype.setPageInput=function(sPageInput){
var sPI=sPageInput;
this.sPI=(sPI.length>0)?sPI:"Page";
}
//輸入 語言 首頁(Disable,Enale)
Cls_jsPage.prototype.setPageFrist=function(sDis,sEn){
this.PF_D=sDis;
this.PF_E=sEn;
}
//輸入 語言 上頁
Cls_jsPage.prototype.setPagePrev=function(sDis,sEn){
this.PP_D=sDis;
this.PP_E=sEn;
}
//輸入 語言 下頁
Cls_jsPage.prototype.setPageNext=function(sDis,sEn){
this.PN_D=sDis;
this.PN_E=sEn;
}
//輸入 語言 尾頁
Cls_jsPage.prototype.setPageLast=function(sDis,sEn){
this.PL_D=sDis;
this.PL_E=sEn;
}
//輸入 語言 數字跳轉
Cls_jsPage.prototype.setPageText=function(sDis,sEn){
this.PT_D=sDis;//"[1]"
this.PT_E=sEn;//"第1頁"
}
//輸入 語言 數字跳轉外圍模板
Cls_jsPage.prototype.setPageTextF=function(sDis,sEn){
this.PTF_D=sDis;//" {$PageTextF} "
this.PTF_E=sEn;//" {$PageTextF} "
}
//輸入 語言 下拉菜單跳轉
Cls_jsPage.prototype.setPageSelect=function(sDis,sEn){
this.PS_D=sDis;//"[1]"
this.PS_E=sEn;//"第1頁"
}
//輸入 css
Cls_jsPage.prototype.setPageCss=function(sCssPageText,sCssPageInput,sCssPageSelect){
this.CPT=sCssPageText;//數字跳轉css
this.CPI=sCssPageInput;//輸入框跳轉css
this.CPS=sCssPageSelect;//下拉菜單跳轉css
}
//輸入 Html模板
Cls_jsPage.prototype.setHtml=function(sHtml){
this.Html=sHtml;//Html模板
}
//計算頁數
Cls_jsPage.prototype.getPageCount=function(){
var iRC=this.iRC,iPS=this.iPS;
var i=(iRC%iPS==0)?(iRC/iPS):(this.FormatNum((iRC/iPS),1,0,0,0)+1);
return (i);
}
//取得模板頁數和當前頁數
Cls_jsPage.prototype.getUrl=function(iType){
var s=this.Url,sPS=this.sPS,sPE=this.sPE,sTP=this.sTPage,iPC=this.iPC;
var iT=iType,i;
if (s.indexOf(sPS)==-1) {
s+=((s.indexOf("?")==-1)?"?":"&")+sPS+sTP;
i=1;
}
else {
sReg="(\\S.*)"+this.FormatReg(sPS)+"(\\d*)"+this.FormatReg(sPE)+"(\\S.*|\\S*)";
var sPIndex=this.Reg(s,sReg,"$3");
s=s.replace(sPS+sPIndex+sPE,sPS+sTP+sPE);
i=this.FormatNum(sPIndex,1,1,0,iPC);
}
s=this.Reg(s,"(&+)","&");
s=this.Reg(s,"(\\?&)","?");
return (iT==0?s:i);
}
//頁面跳轉
Cls_jsPage.prototype.PageJump=function(){
var sPL,sPV,sP;
var sU=this.getUrl(0),iPI=this.getUrl(1);
var sPI=this.sPI,sTP=this.sTPage,iPC=this.iPC;
sPL=document.getElementsByName(sPI).length;
for (var i=0;i<sPL;i++) {
sPV=document.getElementsByName(sPI)[i].value;
sP=this.FormatNum(sPV,1,1,0,iPC);
if (sP>0) {
location.href=sU.replace(sTP,sP);
break;
}
}
}
//輸出
Cls_jsPage.prototype.Write=function(){
var sU=this.getUrl(0),iPI=this.getUrl(1);
var sN=this.sN,sPI=this.sPI;
var iPC=this.iPC,iPN=this.iPN;;
var iRC=this.iRC,iPS=this.iPS;
var PF_D=this.PF_D,PF_E=this.PF_E;
var PP_D=this.PP_D,PP_E=this.PP_E;
var PN_D=this.PN_D,PN_E=this.PN_E;
var PL_D=this.PL_D,PL_E=this.PL_E;
var PT_D=this.PT_D,PT_E=this.PT_E;
var PTF_D=this.PTF_D,PTF_E=this.PTF_E;
var PS_D=this.PS_D,PS_E=this.PS_E;
var CPT=this.CPT,CPI=this.CPI;
var CPS=this.CPS,iPN=this.iPN;
var s=this.Html;
sTPage=this.sTPage;
sTPageCount=this.sTPageCount;
sTRecCount=this.sTRecCount;
sTPageSize=this.sTPageSize;
sTPFrist=this.sTPageFrist;
sTPPrev=this.sTPagePrev;
sTPNext=this.sTPageNext;
sTPLast=this.sTPageLast;
sTPText=this.sTPageText;
sTPTextF=this.sTPageTextF;
sTPInput=this.sTPageInput;
sTPSelect=this.sTPageSelect;
sTPageNum=this.sTPageNum;
var PrevP=this.FormatNum((iPI-1),1,1,1,iPC),NextP=this.FormatNum((iPI+1),1,1,1,iPC);
var FU,PU,NU,LU;
var s1="<span class=\""+CPT+"\"><A href=\"",s2="\">",s3="</A></span>";
var s4="<span class=\""+CPT+"\">",s5="</span>";
if (iPI<=1&&iPC<=1) {
FU=s4+PF_D+s5;
PU=s4+PP_D+s5;
NU=s4+PN_D+s5;
LU=s4+PL_D+s5;
}
else if (iPI==1&&iPC>1) {
FU=s4+PF_D+s5;
PU=s4+PP_D+s5;
NU=s1+sU.replace(sTPage,NextP)+s2+PN_E+s3;
LU=s1+sU.replace(sTPage,iPC)+s2+PL_E+s3;
}
else if (iPI==iPC) {
FU=s1+sU.replace(sTPage,1)+s2+PF_E+s3;
PU=s1+sU.replace(sTPage,PrevP)+s2+PP_E+s3;
NU=s4+PN_D+s5;
LU=s4+PL_D+s5;
}
else {
FU=s1+sU.replace(sTPage,1)+s2+PF_E+s3;
PU=s1+sU.replace(sTPage,PrevP)+s2+PP_E+s3;
NU=s1+sU.replace(sTPage,NextP)+s2+PN_E+s3;
LU=s1+sU.replace(sTPage,iPC)+s2+PL_E+s3;
}
var PageStart,PageEnd;
if (iPN<0) {
iPN=Math.abs(iPN);
PageStart=(iPI%iPN==0)?(iPI/iPN):(this.FormatNum((iPI/iPN),1,0,0,0));
PageStart=(PageStart*iPN==iPI)?((PageStart-1)*iPN+1):(PageStart*iPN+1);
PageEnd=this.FormatNum(PageStart+iPN,0,1,0,iPC)
}
else if (iPN==0) {
PageStart=1;
PageEnd=iPC;
}
else {
PageStart=this.FormatNum((iPI-iPN),1,0,1,0);
PageEnd=this.FormatNum((PageStart+iPN*2),0,1,0,iPC);
PageStart=(PageEnd==iPC)?this.FormatNum((PageEnd-iPN*2),1,0,1,0):PageStart;
}
var PSelect="",PText="",PInput="",p;
if (iPC>=1) {
PSelect="<Select class=\""+CPS+"\" name=\""+sPI+"\" onChange=\""+sN+".PageJump()\">";
PInput="<Input class=\""+CPI+"\" type=\"text\" name=\""+sPI+"\" size=\"5\" maxlength=\"10\" onkeydown=\"if (event.keyCode==13) "+sN+".PageJump()\">";
for (var i=PageStart;i<=PageEnd;i++) {
if (i!=iPI) {
p=s1+sU.replace(sTPage,i)+s2+PT_E.replace(sTPageNum,i)+s3;
PText+=PTF_E.replace(sTPTextF,p);
PSelect+="<Option value=\""+i+"\">"+PS_E.replace(sTPageNum,i)+"</Option>";
}
else {
p=s4+PT_D.replace(sTPageNum,i)+s5;
PText+=PTF_D.replace(sTPTextF,p);
PSelect+="<Option Selected=\"Selected\">"+PS_D.replace(sTPageNum,i)+"</Option>";
}
}
PSelect+="</Select>";
}
s=s.replace(sTPage,iPI);
s=s.replace(sTPageCount,iPC);
s=s.replace(sTRecCount,iRC);
s=s.replace(sTPageSize,iPS);
s=s.replace(sTPFrist,FU);
s=s.replace(sTPPrev,PU);
s=s.replace(sTPNext,NU);
s=s.replace(sTPLast,LU);
s=s.replace(sTPText,PText);
s=s.replace(sTPInput,PInput);
s=s.replace(sTPSelect,PSelect);
document.write (s);
}
//輸入:欲格式化字符,是否有最小值(0表示沒有,1表示有),是否有最大值,最小值(默認值),最大值
Cls_jsPage.prototype.FormatNum=function(sNum,bMin,bMax,iMinNum,iMaxNum){
var i,iN,sN=""+sNum,iMin=iMinNum,iMax=iMaxNum;
if (sN.length>0) {
iN=parseInt(sN,10);
i=(isNaN(iN))?iMin:iN;
i=(i<iMin&&bMin==1)?iMin:i;
i=(i>iMax&&bMax==1)?iMax:i;
}
else {
i=iMin;
}
return (i);
}
//輸入:欲正則字符,正則表達式,替換後字符
Cls_jsPage.prototype.Reg=function(sStr,sReg,sRe){
var s="",sS=sStr,sR=sReg,sRe=sRe;
if ((sS.length>0)&&(sR.length>0)) {
eval("re=/"+sR+"/gim;");
s=sS.replace(re,sRe);
}
return (s);
}
//格式化正則中的特殊字符
Cls_jsPage.prototype.FormatReg=function(sReg){
var s="",sR=sReg;
var sF=new Array ("/",".","+","[","]","{","}","$","^","?","*");
if (sR.length>0) {
for (var i=0;i<=sF.length;i++) {
sR=sR.replace(sF[i],"\\"+sF[i]);
}
s="("+sR+")";
}
return (s);
}
demoAC.asp
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="Cls_vbsPage.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> </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_vbsPage ''創建對象
Set ors.Conn=conn ''得到數據庫連接對象
With ors
.PageSize=13 ''每頁記錄條數
.PageName="Pages" ''cookies名稱
.DbType="AC"
''數據庫類型,AC為access,MSSQL為sqlserver2000存儲過程版,MYSQL為mysql,PGSQL為PostGreSql
.RecType=0
''記錄總數(>0為另外取值再賦予或者固定值,0執行count設置存cookies,-1執行count不設置cookies)
.JsUrl="" ''Cls_jsPage.js的路徑
.Pkey="MID" ''主鍵
.Field="MID,ip2,country,city"
.Table="dv_address"
.Condition="" ''條件,不需要where
.OrderBy="MID DESC" ''排序,不需要order by,需要asc或者desc
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
%>
demoMSSQL.asp
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="Cls_vbsPage.asp"-->
<%
''-----------------------------------------------------------------------------------------------
On Error Resume Next
DIM startime,endtime
''統計執行時間
startime=timer()
''連接數據庫
DIM Db,Conn,Rs
strSQLServerName = "(local)" ''服務器名稱或地址
strSQLDBUserName = "sa" ''數據庫帳號
strSQLDBPassword = "19811030" ''數據庫密碼
strSQLDBName = "showoTemp" ''數據庫名稱
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> </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_vbsPage ''創建對象
Set ors.Conn=conn ''得到數據庫連接對象
With ors
.PageSize=13 ''每頁記錄條數
.PageSize=13 ''每頁記錄條數
.PageName="Pages" ''cookies名稱
.DbType="MSSQL"
''數據庫類型,AC為access,MSSQL為sqlserver2000存儲過程版,MYSQL為mysql,PGSQL為PostGreSql
.RecType=0
''記錄總數(>0為另外取值再賦予或者固定值,0執行count設置存cookies,-1執行count不設置cookies)
.JsUrl="" ''Cls_jsPage.js的路徑
.Pkey="MID" ''主鍵
.Field="MID,ip2,country,city"
.Table="tbTempPage"
.Condition="" ''條件,不需要where
.OrderBy="MID ASC" ''排序,不需要order by,需要asc或者desc
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
%>