您现在的位置: 军旅同心-旅游自驾-军旅文学 >> 读书赏析 >> 学习园地 >> 电脑网络 >> 技术文章 >> 正文
asp中通过getrows实现数据库记录分页的一段代码
作者:采集员 文章来源:来源于网络 点击数: 更新时间:2005-9-10 12:57:37
<%@ 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
%>


更多
免责声明:作品版权归所属媒体与作者所有!!本站刊载此文不代表同意其说法或描述,仅为提供更多信息。如果您认为我们侵犯了您的版权,请告知!本站立即删除。有异议请联系我们。
文章录入:烟灰缸    责任编辑:烟灰缸 
网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
| 设为首页 | 加入收藏 | 联系站长 | 友情链接 | 网站地图 | 版权申明 | 网站公告 | 管理登录 |