作家
登录

asp中通过getrows实现数据库记录分页的一段代码

作者: 来源:www.28hudong.com 2013-03-30 09:01:00 阅读 我要评论

<%@ Language = VBSCRIPT %> <% Option Explicit %> <% rem 在asp中通过getrows实现数据库记录分页的一段代码 Dim iStart, iOffset iStart = Request("Start") iOffset = Request("Offset") if Not IsNumeric(iStart) or Len(iStart) = 0 then iStart = 0 else iStart = CInt(iStart) end if if Not IsNumeric(iOffset) or Len(iOffset) = 0 then iOffset = 30 else iOffset = Cint(iOffset) end if Response.Write "Viewing " & iOffset & " records starting at record " & iStart & "<BR>" Dim objConn, objRS Set objConn = Server.CreateObject("ADODB.Connection") 'objConn.Open "DSN=MP3" dim connstr dim db db="csnjimageman.mdb" connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(""&db&"") objconn.Open connstr Set objRS = Server.CreateObject("ADODB.Recordset") objRS.Open "SELECT * FROM imageinfo", objConn Dim aResults aResults = objRS.GetRows objRS.Close Set objRS = Nothing objConn.Close Set objConn = Nothing Dim iRows, iCols, iRowLoop, iColLoop, iStop iRows = UBound(aResults, 2) iCols = UBound(aResults, 1) If iRows > (iOffset + iStart) Then iStop = iOffset + iStart - 1 Else iStop = iRows End If For iRowLoop = iStart to iStop For iColLoop = 0 to iCols Response.Write aResults(iColLoop, iRowLoop) & " " Next Response.Write "<BR>" Next Response.Write "<P>" if iStart > 0 then 'Show Prev link Response.Write "<A HREF=""GetRows.asp?Start=" & iStart-iOffset & _ "&Offset=" & iOffset & """>Previous " & iOffset & "</A>" end if if iStop < iRows then 'Show Next link Response.Write " <A HREF=""GetRows.asp?Start=" & iStart+iOffset & _ "&Offset=" & iOffset & """>Next " & iOffset & "</A>" end if %>

  推荐阅读

  jb51内容分页函数 原创

复制代码 代码如下:allpages=ubound(contentarray) for dxy_ii=0 to allpages pagelist1="当前"&dxy_ii+1&"/"&(allpages+1)&"页 " pagepre="" pagelast="" if dxy_ii>0 then cpage=cint(dxy_ii) if cpage<0 then c>>>详细阅读


本文标题:asp中通过getrows实现数据库记录分页的一段代码

地址:http://www.17bianji.com/kaifa2/ASP/33134.html

关键词: 探索发现

乐购科技部分新闻及文章转载自互联网,供读者交流和学习,若有涉及作者版权等问题请及时与我们联系,以便更正、删除或按规定办理。感谢所有提供资讯的网站,欢迎各类媒体与乐购科技进行文章共享合作。

网友点评
自媒体专栏

评论

热度

精彩导读
栏目ID=71的表不存在(操作类型=0)