ASP in the implementation of the GetRows database records pagination of a piece of code _ Application skills

Source: Internet
Author: User
<%@ Language = VBSCRIPT%>
<% Option Explicit%>
<%
REM A section of code that implements database record paging through GetRows in ASP
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
%>



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.