Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 22nd, 2004, 10:35 PM
Registered User
 
Join Date: Aug 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem with pagination

Hi,

I have problem with paginating those pages. The problem that i encountered was i jz couldn't display the next 10 records. And even i changed the pagesize to 20. It still jz displayed 10 records at 1 page only..In addition to that, i also tried to print the display number value when i changed the pagesize to 20 but it printed 1 to 10 onli..So can anyone tell me what's the problem with my coding?

The following is my coding:

<%
Dim strConn, objConn
Dim pages, objRs, DisplayNum, i, page, ipage, z
Dim objRsPage, strSQL
Dim RowCount
Dim PageCounter
Dim DateID, RoomID, strPeriod
strConn = "Provider=Microsoft.Jet.OLEDB.4.0; " & _
"Data Source=" & Server.MapPath("dbBooking.mdb") & ";Persist Security Info=False"
Const adOpenForwardOnly = 0
Const adLockReadOnly = 1
Const adUseClient = 3
Const adCmdText = 1

'Get the Current page
page = request.querystring("page")
If page = "" Then
page = 1
else
page = cint(page)
End If
DisplayNum = 0
DateID = Request.QueryString("StartID")
RoomID = Request.QueryString("ID")
Set objConn = Server.CreateObject ("ADODB.Connection")
Set objRs = Server.CreateObject ("ADODB.Recordset")
objConn.Open strConn
objRs.PageSize = 20
objRs.CursorLocation = adUseClient
objRs.CacheSize = 20
strSQL = "SELECT StartBookingDate, LabID, Name,PeriodFrom, PeriodTo, Class FROM LAB_BOOKING INNER JOIN STAFF_LISTS ON LAB_BOOKING.TeachersID = STAFF_LISTS.TeachersID WHERE StartBookingDate= #" & DateID & "# AND LabID= '" & RoomID & "' ORDER BY PeriodFrom"
'objRs.CursorType = 3 'adOpenStatic
objRs.Open strSQL, objConn

if objRs.EOF OR objRs.BOF Then
response.write "<br><br>"
response.write "<p align=center><b>No Records.</b></p>"
response.write "<p align=center><b>To continue, please close this window...</b></p>"
else
ipage = objRs.PageCount
if page = 0 or page > ipage Then
objRs.AbsolutePage = ipage
else
objRs.AbsolutePage = page
end if

Response.Write("<center><H1 style='font-size:24px;'>Facilities Booking Information<br></H1></center>")
Response.Write("<TABLE Align='CENTER' Border=1 CELLSPACING='10' CELLPADDING='1' WIDTH='625'>")
Response.Write("<tr><th>Booking Date(YYYY-MM-DD)</th><th>Lab</th><th>Start</th><th>End</th><th>Name</th><th>Class</th></tr>")
Do While Not objRs.EOF AND DisplayNum<20
Response.Write("<tr><td align= 'center' valign='top' width='300' style='font-size:14px;'>" & objRs("StartBookingDate") & "</td><td valign='top' align= 'center' style='font-size:14px;'>" & objRs("LabID") & "</td><td align= 'center' valign='top' width='200' style='font-size:14px;'>" & objRs("PeriodFrom") & "</td><td align= 'center' valign='top' width='200' style='font-size:14px;'>" & objRs("PeriodTo") & "</td><td align= 'center' valign='top' width='200' style='font-size:14px;'>" & objRs("Name") & "</td><td align= 'center' valign='top' width='200' style='font-size:14px;'>" & objRs("Class") & "</tr>")
DisplayNum = DisplayNum + 1
Response.write(DisplayNum)
objRs.MoveNext
Loop
End If
Response.Write "</TABLE>"
If ipage > 1 Then
response.write "<p align=center>"
pages = "<b>Pages : &nbsp;"
For z = 1 to ipage
If z = page then
pages = pages & page & " "
Else
pages = pages & " <a href=?room="&RoomID&"&Date="&DateID&"&page=" & z & ">" & z & "</a>" & " "
End If
Next
response.write pages & "&nbsp;&nbsp;"
End If
if ipage > 1 And page > 1 Then
response.write "<a href=?room="&RoomID&"&Date="&DateID&"&page="& page - 1 &">Previous</a>"
end if
response.write "&nbsp;&nbsp;"
If ipage > 1 And page < ipage Then
response.write "<a href=?room="&RoomID&"&Date="&DateID&"&page="& page + 1 &">Next Page</a>"
end if
response.write "</b></p>"
objRs.Close
objConn.Close
set objRs = nothing
set objConn = nothing
%>


 
Old August 23rd, 2004, 12:04 AM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 363
Thanks: 0
Thanked 1 Time in 1 Post
Default


Check your data in the database whether you have data in the fields?

 
Old August 23rd, 2004, 12:40 AM
Registered User
 
Join Date: Aug 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by rajanikrishna


Check your data in the database whether you have data in the fields?

Ya. I have checked the database already. I have 15 records but the page could only display 10 records. And I tried to delete 8 records and refreshed the page again. It even didn't show 7 records but it jz showed 4 records onli. I have tried to print the display number only which jz printed 4 rather then 7. So i really don't have any idea with it.. Can you plz help me??

 
Old August 23rd, 2004, 01:59 AM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 363
Thanks: 0
Thanked 1 Time in 1 Post
Default


  Hi,

     I didnt find any error there. Otherwise you follow this link and find the mistake if any.

http://www.asp101.com/articles/recor...ging/index.asp

 
Old August 23rd, 2004, 07:42 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hey,

if objRs.EOF OR objRs.BOF Then

From what I understand, when you open a recordset, it is BOF by default at the start. Maybe just test the EOF condition when you open it? Since you aren't moving records ahead of this check, you probably don't need to test for BOF.

Brian





Similar Threads
Thread Thread Starter Forum Replies Last Post
Pagination problem nanetsu Other Programming Languages 1 June 12th, 2008 06:12 AM
pagination problem solos XSLT 1 April 4th, 2007 05:40 PM
Problem Regarding Pagination!!!!!!!!!!! mohit_malik555 Pro Java 2 August 3rd, 2006 08:06 AM
Please.....Pagination junemo PHP Databases 2 September 25th, 2004 01:14 PM
pagination junemo Oracle 0 July 1st, 2004 04:07 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.