Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Web
Expertise: Intermediate
Dec 21, 2001

The Easiest Way for Recordset Paging Using ADO GetString


The following subroutine requires two parameters

1) Recordset

2) Count of records per page. For example:
 
    Call EasyPaging(Rs,10)


<%
Sub EasyPaging(MyRecordset,RecordsperPage)
 Dim CurrentPage,Myurl
 Myurl=Request.ServerVariables("script_name")
 MyRecordset.PageSize = RecordsperPage:MyRecordset.CacheSize =
RecordsperPage
 'get the current page number
 CurrentPage = Request.QueryString("Page")
 If CurrentPage = "" Or CurrentPage = 0 Then CurrentPage = 1
 MyRecordset.AbsolutePage = CurrentPage

 'write the content
 with Response
   .Write "<table border=0 width=""50%"" cellpadding=2 _
cellspacing=0>"
   .Write "<tr>"
  For Each myfld In MyRecordset.Fields
   .Write "<th width=""50%"" bgcolor='#0000A0' _
align=left><font
color='#FFFFFF'><b>" & myfld.Name & "</b></font></th>"
  Next
   .Write "</tr>"
   .Write "<tr><td width=""50%"">"
  'use getstring
   .write MyRecordset.GetString(2, RecordsperPage, _
"</td><td
width=""50%"">", "</td></tr><tr><td width=""50%"">", " ")
   .Write "</td></tr></table>"

  If CInt(CurrentPage) > 1 Then
   .Write "<a href=""" & Myurl & "?Page=" & _
(CurrentPage - 1 ) &
"""><Previous </a>  "
  End If
  If CInt(CurrentPage) < MyRecordset.PageCount Then
   .Write "<a href=""" & Myurl & "?Page=" & _
(CurrentPage + 1 ) &
""">Next></a>"
  End If

 End With
End Sub
%>
Harinatha Reddy
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date