当前位置:编程学习 > asp >>

在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)
补充:asp教程,技巧与性能优化
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,