欢迎光临
我们一直在努力

在asp中通过getrows实现数据库记录分页的一段代码,希望对大家有用

建站超值云服务器,限时71元/月

<%@ 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
%>

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 在asp中通过getrows实现数据库记录分页的一段代码,希望对大家有用
分享到: 更多 (0)