三度网教程:是一个免费提供流行视频软件教程、在线学习分享的学习平台!

在asp中通过getrows完成数据库记录分页的一段代码

时间:2024/6/1作者:未知来源:三度网教程人气:


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


关键词:  在asp中通过getrows完成数据库记录分页的一段代码





Copyright © 2012-2018 三度网教程(http://www.3du8.cn) .All Rights Reserved 网站地图 友情链接

免责声明:本站资源均来自互联网收集 如有侵犯到您利益的地方请及时联系管理删除,敬请见谅!

QQ:1006262270   邮箱:kfyvi376850063@126.com   手机版