asp+mssql2000存储过程

1.mssql2000存储过程

 

/*
分页
调用方法:exec sp_Util_Page 440000,4,10,'MID','MID,ip1,ip2,country,city','tbTempPage','1=1','mid asc'
输入:
 1.记录条数(已有值:外部赋值,0执行count)
 2.当前页数
 3.每页记录数
 4.主键(一定要有)
 5.字段
 6.表名
 7.条件(不需要where)
 8.排序(不需要order by,需要asc和desc字符)
返回:记录集
*/
CREATE PROCEDURE sp_Util_Page
(
 @iRecordCount int OUTPUT,
 @iPageCurr int,
 @iPageSize int,
 @sPkey nvarchar(50),
 @sField nvarchar(1000),
 @sTable nvarchar(100),
 @sCondition nvarchar(1000),
 @sOrder nvarchar(100)
)
AS
BEGIN
 SET NOCOUNT ON
 DECLARE @sCond1 nvarchar(1000),@sCond2 nvarchar(1000)
 DECLARE @iAsc int,@iDesc int,@iType tinyint
 DECLARE @sTmp nvarchar(1000),@sOrderTmp nvarchar(1000),@sSQL nvarchar(4000)

 IF LEN(@sCondition)>2
  SELECT @sCond1=' WHERE '+@sCondition+' ', @sCond2=' WHERE '+@sCondition+' AND '
 ELSE
  BEGIN
   SELECT @sCond1='', @sCond2=' WHERE '
  END

 IF LEN(@sOrder)<4
  SELECT @iType=0, @sOrder=''
 Else
  BEGIN   
   SET @sOrderTmp=UPPER(@sOrder)
   IF CHARINDEX(UPPER(@sPkey),@sOrderTmp)=1--存在主建
     SELECT @iAsc=CHARINDEX('ASC',@sOrderTmp), @iDesc=CHARINDEX('DESC',@sOrderTmp)
   ELSE
    BEGIN
     SELECT @iAsc=0, @iDesc=0
    END

   IF (@iAsc>0 and @iDesc=0) OR ((@iAsc>0 AND @iDesc>0) AND (@iAsc<@iDesc))
    SELECT @iType=1, @sTmp='>(SELECT MAX('
   ELSE IF (@iAsc=0 and @iDesc>0) OR ((@iAsc>0 AND @iDesc>0) AND (@iAsc>@iDesc))
    SELECT @iType=1, @sTmp='<(SELECT MIN('
   ELSE
    BEGIN
     SELECT @iType=0
    END
   SET @sOrder=' ORDER BY '+@sOrder
  END

 IF @iRecordCount<1
  BEGIN
   SET @sSQL='SELECT @iRecordCount=Count(0) FROM '+@sTable+@sCond1
   EXEC sp_executesql @sSQL,N'@iRecordCount int OUT',@iRecordCount OUT
  END

 IF @iRecordCount<(@iPageCurr-1)*@iPageSize
  SET @iPageCurr=CEILING(@iRecordCount/@iPageSize)
 ELSE IF @iPageCurr<1
  BEGIN
   SET @iPageCurr=1
  END

 IF @iPageCurr=1
  SET @sSQL='SELECT TOP '+CAST(@iPageSize AS nvarchar)+' '+@sField+' FROM '+@sTable+@sCond1+@sOrder
 ELSE
  BEGIN
   IF @iType=1
    SET @sSQL='SELECT TOP '+CAST(@iPageSize AS nvarchar)+' '+@sField+' FROM '+@sTable+@sCond2+@sPkey+@sTmp+@sPkey+') FROM (SELECT TOP '+CAST((@iPageCurr-1)*@iPageSize AS nvarchar)+' '+@sPkey+' FROM '+@sTable+@sCond1+@sOrder+') AS tbTemp)'+@sOrder
   ELSE
    SET @sSQL='SELECT '+@sField+' FROM '+@sTable+@sCond2+@sPkey+' IN (SELECT TOP '+CAST(@iPageSize AS nvarchar)+' '+@sPkey+' FROM '+@sTable+@sCond2+@sPkey+' NOT IN(SELECT TOP '+CAST((@iPageCurr-1)*@iPageSize AS nvarchar)+' '+@sPkey+' FROM '+@sTable+@sCond1+@sOrder+')'+@sOrder+')'+@sOrder
  END
 --PRINT(@sSQL)
 --RETURN(@iRecordCount)
 EXEC(@sSQL)
 
END

GO

 

 

2.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
 Private sPageURL

 '================================================================
 ' 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
 
 '================================================================
 ' PageURL 设置连接页面
 '================================================================
 Public Property Let PageURL(ByVal strPage)
  sPageURL=strPage
 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)
  dim s
  s=strCondition
  sCondition=IIf(Len(s)>2," WHERE "&s,"")
 End Property

 '================================================================
 ' OrderBy 取得排序
 '================================================================
 Public Property Let OrderBy(ByVal strOrderBy)
  dim s
  s=strOrderBy
  sOrderBy=IIf(Len(s)>4," ORDER BY "&s,"")
 End Property

 '================================================================
 ' RecCount 修正记录总数
 '================================================================
 Public Property Get RecCount()
  dim s,i
  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()
  dim s,i,iPageCount,iPageCurr,rs,cm,ResultSet_Sql
  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_Page.js"></Script>
  <Script Language="JavaScript" type="text/JavaScript">
  var s= new Cls_jsPage(<%=iRecCount%>,<%=iPageSize%>,5,"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("","sInput","","sButton");
  s.setHtml("共{$RecCount}记录 页次{$Page}/{$PageCount} 每页{$PageSize}条 {$PageFrist} {$PagePrev} {$PageText} {$PageNext} {$PageLast} {$PageInput}"); // {$PageSelect}
  s.Write();
  </Script>
 <%End Sub

End Class

%>

 

3.javascript代码


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="{$PageNum}";//数字页数
 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;//"[{$PageNum}]"
 this.PT_E=sEn;//"第{$PageNum}页"
}
//输入 语言 数字跳转外围模板
Cls_jsPage.prototype.setPageTextF=function(sDis,sEn){
 this.PTF_D=sDis;//"&nbsp;{$PageTextF}&nbsp;"
 this.PTF_E=sEn;//"&nbsp;{$PageTextF}&nbsp;"
}
//输入 语言 下拉菜单跳转
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,sCssPageButton){
 this.CPT=sCssPageText;//数字跳转css
 this.CPI=sCssPageInput;//输入框跳转css
 this.CPS=sCssPageSelect;//下拉菜单跳转css
 this.CPB=sCssPageButton;//跳转按钮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;CPB=this.CPB;
 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=/"4/" maxlength=/"10/" οnkeydοwn=/"if (event.keyCode==13) "+sN+".PageJump()/"><Input type=/"button/" value=/"GO/" οnclick=/""+sN+".PageJump()/" class=/""+CPB+"/">";
  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);
}
 

 

调用类

<table align="center" cellpadding="0" cellspacing="0" width="100%" style="zoom:125%; ">
 <%
 Dim ors,iRecCount,iRs,i
 Set ors=new Cls_vbsPage  '创建对象
 Set ors.Conn=conn    '得到数据库连接对象
   ors.PageSize=8   '每页记录条数
   ors.PageName="Page"  'cookies名称
   ors.DbType="MSSQL"  '数据库类型,AC为access,MSSQL为sqlserver2000存储过程版
   ors.RecType=0    '记录总数(>0为另外取值再赋予或者固定值,0执行count设置存cookies,-1执行count不设置cookies)
   ors.JsUrl="/js/"   'Cls_jsPage.js的路径
        '.PageURL="Clienterrreport.asp?1=1"
   ors.Pkey="channelid"  '主键
   ors.Field="channelid,channelname,channelpic,kindid,webname,subdomain,webdomain,needvalidate,isclosed,ischecked"
   ors.Table="tv_channel"
   ors.Condition= sql  '条件,不需要where
   ors.OrderBy= "addeddate desc"  '排序,不需要order by,需要asc或者desc
 
 iRecCount=ors.RecCount()  '记录总数
 iRs=ors.ResultSet()   '返回ResultSet
 If  iRecCount<1 Then
 response.Write "<tr><td colspan=""10"" height=""50"" align=""center"">目前还没有创建任何频道,你可以点击“<a href=""mychannel_add.asp"">创建频道</a>”来建立你的频道。</td></tr>"
 Else
 For i=0 To Ubound(iRs,2)
 %>
 <tr onMouseOver="this.bgColor='#e2e2e2'" onMouseOut="this.bgColor='#ffffff'">
  <td height="15" width="25%" align="left"  style="border-bottom:1px dotted #ccc; padding-left:2px; "><%=irs(1,i)%></td>
  <td width="25%" align="left"  style="border-bottom:1px dotted #ccc;"><%=irs(4,i)%></td>
  <td width="34%" align="left"  style="border-bottom:1px dotted #ccc;"><%=irs(6,i)%></td>
  <td width="8%" align="center"  style="border-bottom:1px dotted #ccc;"><img src="../images/play.gif" style="cursor:hand; border:0px; " onClick="view_channel(<%=irs(0,i)%>)"></td>
  <td width="8%" align="center" style="border-bottom:1px dotted #ccc;"><img src="../images/add.gif" style="cursor:hand; border:0px "></td>
 </tr>
 <%
 next
 end if
 %>
 <tr>
  <td colspan="5" align="right">    <%
     ors.ShowPage()
      iRs=NULL
         ors=NULL
         Set ors=NoThing%>
   </td>
 </tr>
</table>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值