网站首页 | 文章中心 | 源码中心 | 虚拟主机 | 域名注册 |  贺卡源码 | Java特效 |
您现在的位置: 人文中国 >> 文章中心 >> asp基础 >> 文章正文

  没有公告

asp中通过getrows实现数据库记录分页的一段代码     ★★★★★ 【字体:
asp中通过getrows实现数据库记录分页的一段代码
作者:renwen    文章来源:本站原创    点击数:    更新时间:2004-6-23
<%@ 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
%>


文章录入:renwen@renwen.net    责任编辑:renwen@renwen.net 
  • 上一篇文章:

  • 下一篇文章:
  • 发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
    最新热点 最新推荐 相关文章
    视频文件合并转换技巧
    如何搞好IIS的安全?
    企业网管员之对抗BT下载7种武…
    破解ACCESS的数据库密码
    破解ACCESS的数据库密码
    mssql 数据库的备份与恢复
    ASP数据库编程技巧
    ASP编码优化
      网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)