虚位以待(AD)
虚位以待(AD)
首页 > 网络编程 > ASP编程 > ASP编程中通过getrows达到数据库记录分页的一段代码

ASP编程中通过getrows达到数据库记录分页的一段代码
类别:ASP编程   作者:码皇   来源:互联网   点击:

Previous " &amp; iOffset &amp; "" end if if iStop < iRows then   & 039;Show Next link  Response Write "          "&amp;Offset=" &amp; iOffset &amp; """>Next " &amp; iOffset &amp; ,魔客吧
<%@ 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 & "
"
 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 "
"
 Next 
 Response.Write "

"
 if iStart > 0 then
  'Show Prev link
  Response.Write "         "&Offset=" & iOffset & """>Previous " & iOffset & ""
 end if
 if iStop < iRows then
  'Show Next link
  Response.Write "          "&Offset=" & iOffset & """>Next " & iOffset & ""
 end if
%>

相关热词搜索: ASP编程中通过getrows达到数据库记录分页的