叶子asp分页类_ASP教程-查字典教程网
叶子asp分页类
叶子asp分页类
发布时间:2016-12-29 来源:查字典编辑
摘要:名称:叶子asp分页类Name:ShowoPage(vbsclass)RCSfile:ReadMe.txtRevision:0.12.200...

名称:叶子asp分页类

Name:ShowoPage(vbsclass)

RCSfile:ReadMe.txt

Revision:0.12.20051114.f

Author:Yehe(叶子)

Released:2005-11-1409:40:13

Descript:ASP分页类,支持access/mssql/mysql/sqlite

Contact:QQ:311673MSN:myehe@msn.comGT:mmyehe@gmail.com

WebSite:http://www.yehe.orghttp://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调用方法:

execsp_Util_Page440000,4,10,''MID'',''MID,ip1,ip2,country,city'',''tbTempPage'',''1=1'',''midasc''

记录条数(已有值:序外部赋值,0执行count),当前页数,每页记录数,主键,字段,表,条件(不需要where),排序(不需要orderby,需要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.vbsbug修正

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.mdbaccess测试数据库

db/IPmssql备份测试数据库

Cls_vbsPage.asp分页类

Cls_jsPage.jsjs分页样式

sp_Util_Page.sqlmssql存储过程

demoAC.aspac分页调用示范

demoMSSQL.aspmssql调用示范

demoMSSQL_SP.aspmssql存储过程调用示范

Cls_vbsPage.asp

<%

ClassCls_vbsPage

PrivateoConn''连接对象

PrivateiPagesize''每页记录数

PrivatesPageName''地址栏页数参数名

PrivatesDbType

''数据库类型,AC为access,MSSQL为SQLSERVER2000存储过程版,MYSQL为mysql,PGSQL为PostGreSql

PrivateiRecType''记录总数(>0为另外取值再赋予或者固定值,0执行count设置存cookies,-1执行count不设置cookies)

PrivatesJsUrl''Cls_jsPage.js的路径

PrivatesField''字段名

PrivatesTable''表名

PrivatesCondition''条件,不需要where

PrivatesOrderBy''排序,不需要orderby,需要asc或者desc

PrivatesPkey''主键,必写

PrivateiRecCount

''================================================================

''Class_Initialize类的初始化

''================================================================

PrivateSubClass_Initialize

iPageSize=10

sPageName="Page"

sDbType="AC"

iRecType=0

sJsUrl=""

sField="*"

EndSub

''================================================================

''Conn得到数据库连接对象

''================================================================

PublicPropertySetConn(ByRefValue)

SetoConn=Value

EndProperty

''================================================================

''PageSize设置每一页记录条数,默认10记录

''================================================================

PublicPropertyLetPageSize(ByValintPageSize)

iPageSize=CheckNum(intPageSize,0,0,iPageSize,0)

EndProperty

''================================================================

''PageName地址栏页数参数名

''================================================================

PublicPropertyLetPageName(ByValstrPageName)

sPageName=IIf(Len(strPageName)<1,sPageName,strPageName)

EndProperty

''================================================================

''DbType得到数据库类型

''================================================================

PublicPropertyLetDbType(ByValstrDbType)

sDbType=UCase(IIf(Len(strDbType)<1,sDbType,strDbType))

EndProperty

''================================================================

''RecType取记录总数(>0为赋值或者固定值,0执行count设置存cookies,-1执行count不设置cookies适用于搜索)

''================================================================

PublicPropertyLetRecType(ByValintRecType)

iRecType=CheckNum(intRecType,0,0,iRecType,0)

EndProperty

''================================================================

''JsUrl取得Cls_jsPage.js的路径

''================================================================

PublicPropertyLetJsUrl(ByValstrJsUrl)

sJsUrl=strJsUrl

EndProperty

''================================================================

''Pkey取得主键

''================================================================

PublicPropertyLetPkey(ByValstrPkey)

sPkey=strPkey

EndProperty

''================================================================

''Field取得字段名

''================================================================

PublicPropertyLetField(ByValstrField)

sField=IIf(Len(strField)<1,sField,strField)

EndProperty

''================================================================

''Table取得表名

''================================================================

PublicPropertyLetTable(ByValstrTable)

sTable=strTable

EndProperty

''================================================================

''Condition取得条件

''================================================================

PublicPropertyLetCondition(ByValstrCondition)

s=strCondition

sCondition=IIf(Len(s)>2,"WHERE"&s,"")

EndProperty

''================================================================

''OrderBy取得排序

''================================================================

PublicPropertyLetOrderBy(ByValstrOrderBy)

s=strOrderBy

sOrderBy=IIf(Len(s)>4,"ORDERBY"&s,"")

EndProperty

''================================================================

''RecCount修正记录总数

''================================================================

PublicPropertyGetRecCount()

IfiRecType>0Then

i=iRecType

ElseifiRecType=0Then

i=CheckNum(Request.Cookies("ShowoPage")(sPageName),1,0,0,0)

s=Trim(Request.Cookies("ShowoPage")("sCond"))

IFi=0ORsCondition<>sThen

i=oConn.Execute("SELECTCOUNT("&sPkey&")FROM"&sTable&""&sCondition,0,1)(0)

Response.Cookies("ShowoPage")(sPageName)=i

Response.Cookies("ShowoPage")("sCond")=sCondition

EndIf

Else

i=oConn.Execute("SELECTCOUNT("&sPkey&")FROM"&sTable&""&sCondition,0,1)(0)

EndIf

iRecCount=i

RecCount=i

EndProperty

''================================================================

''ResultSet返回分页后的记录集

''================================================================

PublicPropertyGetResultSet()

s=Null

''记录总数

i=iRecCount

''当前页

Ifi>0Then

iPageCount=Abs(Int(-Abs(i/iPageSize)))''页数

iPageCurr=CheckNum(Request.QueryString(sPageName),1,1,1,iPageCount)''当前页

SelectCasesDbType

Case"MSSQL"''sqlserver2000数据库存储过程版

SetRs=server.CreateObject("Adodb.RecordSet")

SetCm=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,"ORDERBY","")

Rs.CursorLocation=3

Rs.LockType=1

Rs.OpenCm

Case"MYSQL"''MYSQL数据库

ResultSet_Sql="SELECT"&sField&"FROM"&sTable&""&sCondition&""&sOrderBy&"LIMIT"&(iPageCurr-1)*iPageSize&","&iPageSize

SetRs=oConn.Execute(ResultSet_Sql)

CaseElse''其他情况按最原始的方法处理(AC同理)

SetRs=Server.CreateObject("Adodb.RecordSet")

ResultSet_Sql="SELECT"&sField&"FROM"&sTable&""&sCondition&""&sOrderBy

Rs.OpenResultSet_Sql,oConn,1,1,&H0001

Rs.AbsolutePosition=(iPageCurr-1)*iPageSize+1

EndSelect

s=Rs.GetRows(iPageSize)

Rs.close

SetRs=Nothing

EndIf

ResultSet=s

EndProperty

''================================================================

''Class_Terminate类注销

''================================================================

PrivateSubClass_Terminate()

IfIsObject(oConn)ThenoConn.Close:SetoConn=Nothing

EndSub

''================================================================

''输入:检查字符,是否有最小值,是否有最大值,最小值(默认数字),最大值

''================================================================

PrivateFunctionCheckNum(ByValstrStr,ByValblnMin,ByValblnMax,ByValintMin,ByValintMax)

Dimi,s,iMi,iMa

s=Left(Trim(""&strStr),32):iMi=intMin:iMa=intMax

IfIsNumeric(s)Then

i=CDbl(s)

i=IIf(blnMin=1Andi<iMi,iMi,i)

i=IIf(blnMax=1Andi>iMa,iMa,i)

Else

i=iMi

EndIf

CheckNum=i

EndFunction

''================================================================

''输入:简化条件判断

''================================================================

PrivateFunctionIIf(ByValblnBool,ByValstrStr1,ByValstrStr2)

Dims

IfblnBoolThen

s=strStr1

Else

s=strStr2

EndIf

IIf=s

EndFunction

''================================================================

''上下页部分

''================================================================

PublicSubShowPage()%>

<ScriptLanguage="JavaScript"type="text/JavaScript"src="<%=sJsUrl%>Cls_jsPage.js"></Script>

<ScriptLanguage="JavaScript"type="text/JavaScript">

vars=newCls_jsPage(<%=iRecCount%>,<%=iPageSize%>,3,"s");

s.setPageSE("<%=sPageName%>=","");

s.setPageInput("<%=sPageName%>");

s.setUrl("");

s.setPageFrist("首页","<<");

s.setPagePrev("上页","<");

s.setPageNext("下页",">");

s.setPageLast("尾页",">>");

s.setPageText("[{$PageNum}]","第{$PageNum}页");

s.setPageTextF("{$PageTextF}","{$PageTextF}");

s.setPageSelect("{$PageNum}","第{$PageNum}页");

s.setPageCss("","","");

s.setHtml("共{$RecCount}记录页次{$Page}/{$PageCount}每页{$PageSize}条{$PageFrist}{$PagePrev}{$PageText}{$PageNext}{$PageLast}{$PageInput}{$PageSelect}");

s.Write();

</Script>

<%EndSub

EndClass%>

Cls_jsPage.js

/**

*=================================================================

*Name:叶子js分页样式(ShowoPageStyleWithJS)

*RCSfile:Cls_jsPage.js

*Revision:0.09

*Author:Yehe(叶子)

*Released:2005-05-1223:00:15

*Description:js分页样式,显示上一页下一页的翻页结果

*Contact:QQ:311673,MSN:myehe@msn.com

*WebSite:http://www.yehe.org,http://www.showo.com

*=================================================================

*/

functionCls_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="{$PageNum}";//数字页数

this.iPC=this.getPageCount();//得到页数

}

//输入页数开始值,结尾值

Cls_jsPage.prototype.setPageSE=function(sPageStart,sPageEnd){

varsPS=sPageStart,sPE=sPageEnd;

this.sPS=(sPS.length>0)?sPS:"Page=";

this.sPE=(sPE.length>0)?sPE:"";

}

//输入网址

Cls_jsPage.prototype.setUrl=function(sUrl){

vars=sUrl;

this.Url=(s.length>0)?s:""+document.location;

}

//输入输入框&下拉框name值

Cls_jsPage.prototype.setPageInput=function(sPageInput){

varsPI=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;//"[{$PageNum}]"

this.PT_E=sEn;//"第{$PageNum}页"

}

//输入语言数字跳转外围模板

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;//"[{$PageNum}]"

this.PS_E=sEn;//"第{$PageNum}页"

}

//输入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(){

variRC=this.iRC,iPS=this.iPS;

vari=(iRC%iPS==0)?(iRC/iPS):(this.FormatNum((iRC/iPS),1,0,0,0)+1);

return(i);

}

//取得模板页数和当前页数

Cls_jsPage.prototype.getUrl=function(iType){

vars=this.Url,sPS=this.sPS,sPE=this.sPE,sTP=this.sTPage,iPC=this.iPC;

variT=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*)";

varsPIndex=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(){

varsPL,sPV,sP;

varsU=this.getUrl(0),iPI=this.getUrl(1);

varsPI=this.sPI,sTP=this.sTPage,iPC=this.iPC;

sPL=document.getElementsByName(sPI).length;

for(vari=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(){

varsU=this.getUrl(0),iPI=this.getUrl(1);

varsN=this.sN,sPI=this.sPI;

variPC=this.iPC,iPN=this.iPN;;

variRC=this.iRC,iPS=this.iPS;

varPF_D=this.PF_D,PF_E=this.PF_E;

varPP_D=this.PP_D,PP_E=this.PP_E;

varPN_D=this.PN_D,PN_E=this.PN_E;

varPL_D=this.PL_D,PL_E=this.PL_E;

varPT_D=this.PT_D,PT_E=this.PT_E;

varPTF_D=this.PTF_D,PTF_E=this.PTF_E;

varPS_D=this.PS_D,PS_E=this.PS_E;

varCPT=this.CPT,CPI=this.CPI;

varCPS=this.CPS,iPN=this.iPN;

vars=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;

varPrevP=this.FormatNum((iPI-1),1,1,1,iPC),NextP=this.FormatNum((iPI+1),1,1,1,iPC);

varFU,PU,NU,LU;

vars1="<spanclass=""+CPT+""><Ahref="",s2="">",s3="</A></span>";

vars4="<spanclass=""+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;

}

elseif(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;

}

elseif(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;

}

varPageStart,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)

}

elseif(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;

}

varPSelect="",PText="",PInput="",p;

if(iPC>=1){

PSelect="<Selectclass=""+CPS+""name=""+sPI+""onChange=""+sN+".PageJump()">";

PInput="<Inputclass=""+CPI+""type="text"name=""+sPI+""size="5"maxlength="10"onkeydown="if(event.keyCode==13)"+sN+".PageJump()">";

for(vari=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+="<Optionvalue=""+i+"">"+PS_E.replace(sTPageNum,i)+"</Option>";

}

else{

p=s4+PT_D.replace(sTPageNum,i)+s5;

PText+=PTF_D.replace(sTPTextF,p);

PSelect+="<OptionSelected="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){

vari,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){

vars="",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){

vars="",sR=sReg;

varsF=newArray("/",".","+","[","]","{","}","$","^","?","*");

if(sR.length>0){

for(vari=0;i<=sF.length;i++){

sR=sR.replace(sF[i],""+sF[i]);

}

s="("+sR+")";

}

return(s);

}

demoAC.asp

<%@LANGUAGE="VBSCRIPT"CODEPAGE="936"%>

<>

<%

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

OnErrorResumeNext

DIMstartime,endtime

''统计执行时间

startime=timer()

''连接数据库

DIMDb,Conn,Rs

Db="Provider=Microsoft.Jet.OLEDB.4.0;DataSource="&Server.MapPath("db/IP.mdb")

SetConn=Server.CreateObject("ADODB.Connection")

Conn.openDb

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

%>

<html>

<head>

<title>叶子ASP分页类-access调用示范</title>

<metahttp-equiv="Content-Type"content="text/html;charset=gb2312">

<styletype="text/css">

<>

</style>

</head>

<bodybgcolor="#FFFFFF"text="#000000">

<tablewidth="760"border="0"cellspacing="2"cellpadding="2"align="center"height="30">

<tr>

<td></td>

</tr>

</table>

<tablewidth="760"border="1"cellspacing="0"cellpadding="4"align="center"bordercolordark="#FFFFFF"bordercolorlight="#CCCCCC">

<tralign="center">

<tdwidth="20">ID</td>

<td>标题</td>

<td>内容(显示前20个字)</td>

<td>时间</td>

</tr>

<%

Dimors

Setors=newCls_vbsPage''创建对象

Setors.Conn=conn''得到数据库连接对象

Withors

.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="MIDDESC"''排序,不需要orderby,需要asc或者desc

EndWith

iRecCount=ors.RecCount()''记录总数

iRs=ors.ResultSet()''返回ResultSet

IfiRecCount<1Then%>

<trbgcolor="">

<td>暂无记录</td>

</tr>

<%

Else

Fori=0ToUbound(iRs,2)%>

<trbgcolor="#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

EndIf

%>

</table>

<tablewidth="760"border="0"cellspacing="2"cellpadding="2"align="center">

<tr>

<td>

<%ors.ShowPage()%>

</td>

</tr>

</table>

<tablewidth="760"border="0"align="center"cellpadding="2"cellspacing="2">

<tr>

<tdalign="center">

<%endtime=timer()%>

本页面执行时间:<%=FormatNumber((endtime-startime)*1000,3)%>毫秒</td>

</tr>

</table>

</body>

</html>

<%

iRs=NULL

ors=NULL

Setors=NoThing

%>

demoMSSQL.asp

<%@LANGUAGE="VBSCRIPT"CODEPAGE="936"%>

<>

<%

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

OnErrorResumeNext

DIMstartime,endtime

''统计执行时间

startime=timer()

''连接数据库

DIMDb,Conn,Rs

strSQLServerName="(local)"''服务器名称或地址

strSQLDBUserName="sa"''数据库帐号

strSQLDBPassword="19811030"''数据库密码

strSQLDBName="showoTemp"''数据库名称

SetConn=Server.CreateObject("ADODB.Connection")

Db="Provider=SQLOLEDB.1;PersistSecurityInfo=False;Server="&strSQLServerName&";UserID="&strSQLDBUserName&";Password="&strSQLDBPassword&";Database="&strSQLDBName&";"

Conn.openDb

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

%>

<html>

<head>

<title>叶子ASP分页类-mssql调用示范</title>

<metahttp-equiv="Content-Type"content="text/html;charset=gb2312">

<styletype="text/css">

<>

</style>

</head>

<bodybgcolor="#FFFFFF"text="#000000">

<tablewidth="760"border="0"cellspacing="2"cellpadding="2"align="center"height="30">

<tr>

<td></td>

</tr>

</table>

<tablewidth="760"border="1"cellspacing="0"cellpadding="4"align="center"bordercolordark="#FFFFFF"bordercolorlight="#CCCCCC">

<tralign="center">

<tdwidth="20">ID</td>

<td>标题</td>

<td>内容(显示前20个字)</td>

<td>时间</td>

</tr>

<%

Dimors

Setors=newCls_vbsPage''创建对象

Setors.Conn=conn''得到数据库连接对象

Withors

.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="MIDASC"''排序,不需要orderby,需要asc或者desc

EndWith

iRecCount=ors.RecCount()''记录总数

iRs=ors.ResultSet()''返回ResultSet

IfiRecCount<1Then%>

<trbgcolor="">

<td>暂无记录</td>

</tr>

<%

Else

Fori=0ToUbound(iRs,2)%>

<trbgcolor="#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

EndIf

%>

</table>

<tablewidth="760"border="0"cellspacing="2"cellpadding="2"align="center">

<tr>

<td>

<%ors.ShowPage()%>

</td>

</tr>

</table>

<tablewidth="760"border="0"align="center"cellpadding="2"cellspacing="2">

<tr>

<tdalign="center">

<%endtime=timer()%>

本页面执行时间:<%=FormatNumber((endtime-startime)*1000,3)%>毫秒</td>

</tr>

</table>

</body>

</html>

<%

iRs=NULL

ors=NULL

Setors=NoThing

%>

相关阅读
推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
  • 大家都在看
  • 小编推荐
  • 猜你喜欢
  • 最新ASP教程学习
    热门ASP教程学习
    编程开发子分类