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


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



相关阅读:
网站架设:让IIS支持PHP的配置方法
Windows7稳定性验证
CSS3特效实例:11个CSS3代码特效实例
JavaScript 自动在表格前面增加序号
代码生成器 document.write()
如何给Linux操作系统减肥下
在LINUX平台下写SHELL脚本
javascript 数组
一些很酷的.Net技巧
css 实现文字垂直居中
一个命令行(批处理)延迟执行命令的语法
面向对象的JavaScript(一) — 类及类的继承
Javascript MD4
声明一个变量,为它赋值,然后显示出来
快速导航

Copyright © 2016 phpStudy |