Hi
I have based the following code upon a ASP101.com ( tutoral. but what i gather is the page numbers start form 1, but with this code they have started from 0
this is part of my custom forum, for my website. it accesses an ACCESS 2000 database on a win 2k machine running IIS
the forum has Area -> Forum -> Topic -> Replies
the code is taken from the Area Page this just lists the areas and links them to the relevent Forums
I made 6 areas to test the page, I loaded the page with no page number in the URL ie index.asp?page=1, i just used index.asp
it loaded but show the last 1 not the previous 5
to see it running goto the site is not up premenantly cos I host it myself
if you try
this it lists the first 5
IS THIS CORRECT??
here is the code
<% 'testing verion
dim oRS 'recordset varible
dim numPages 'the number of pages
dim mumRecords 'the total number of records
dim CPage 'the Current page
dim CRecord 'The record counter, used in the main loop
'dim Finish 'the record that the cursor finishes on
'dim Start 'the record that the cirsor starts on
dim sqlopen 'the sql statment
'to see if there is a page in the URL
if request.QueryString("page" = "" then
Cpage = 1
else
cpage = int(request.QueryString("page")
end if
'SQL string
sqlopen = "SELECT * FROM Area"
'set Recordset object
Set oRS=Server.CreateObject("ADODB.Recordset"
'set recordset cursor types
oRS.CursorLocation = 3 'adUseClient
ors.CursorType = 3 'adOpenStatic
'open recordset
oRS.Open sqlopen, oConn
'setting the pagesize
oRS.pagesize = 5
'setting the cache size
oRS.cachesize = oRS.pagesize
'find the number of pages and records
numPages = cint(oRS.PageCount)
numRecords = cint(oRS.RecordCount)
'this is a failsafe. this makes sure that the Cpage is not out of
'the recordset range
'if the current page is over the total page count then change
'it to the last page
if CPage > numPage then CPage = numPages
'now if the CPage is below the the recordset
if CPage <= 0 then CPage = 1
'set the current page pointer
If numRecords > 0 Then
oRS.AbsolutePage = int(CPage)
End If
CRecord = 1
if not ors.bof or not ors.eof then
do
%>
<tr>
<td><font color="#333333" size="2" face="Verdana, Arial, Helvetica, sans-serif">
<% response.write "<a href=" & chr(34) & "forum.asp?AID=" & ors.fields("aid" & chr(34) &">" & ors.fields("Aname" & "</a>" %>
</font></td>
<td><font color="#333333" size="2" face="Verdana, Arial, Helvetica, sans-serif">
<% response.write ors.fields("aforumno" %>
</font></td>
</tr>
<%
ors.movenext
CRecord = CRecord + 1
loop until (ors.Eof) or (CRecord = oRS.pagesize)
end if
oRS=close
%>
</table>
Thanx for any help
Geo
--
the student will become the master
I have based the following code upon a ASP101.com ( tutoral. but what i gather is the page numbers start form 1, but with this code they have started from 0
this is part of my custom forum, for my website. it accesses an ACCESS 2000 database on a win 2k machine running IIS
the forum has Area -> Forum -> Topic -> Replies
the code is taken from the Area Page this just lists the areas and links them to the relevent Forums
I made 6 areas to test the page, I loaded the page with no page number in the URL ie index.asp?page=1, i just used index.asp
it loaded but show the last 1 not the previous 5
to see it running goto the site is not up premenantly cos I host it myself
if you try
this it lists the first 5
IS THIS CORRECT??
here is the code
<% 'testing verion
dim oRS 'recordset varible
dim numPages 'the number of pages
dim mumRecords 'the total number of records
dim CPage 'the Current page
dim CRecord 'The record counter, used in the main loop
'dim Finish 'the record that the cursor finishes on
'dim Start 'the record that the cirsor starts on
dim sqlopen 'the sql statment
'to see if there is a page in the URL
if request.QueryString("page" = "" then
Cpage = 1
else
cpage = int(request.QueryString("page")
end if
'SQL string
sqlopen = "SELECT * FROM Area"
'set Recordset object
Set oRS=Server.CreateObject("ADODB.Recordset"
'set recordset cursor types
oRS.CursorLocation = 3 'adUseClient
ors.CursorType = 3 'adOpenStatic
'open recordset
oRS.Open sqlopen, oConn
'setting the pagesize
oRS.pagesize = 5
'setting the cache size
oRS.cachesize = oRS.pagesize
'find the number of pages and records
numPages = cint(oRS.PageCount)
numRecords = cint(oRS.RecordCount)
'this is a failsafe. this makes sure that the Cpage is not out of
'the recordset range
'if the current page is over the total page count then change
'it to the last page
if CPage > numPage then CPage = numPages
'now if the CPage is below the the recordset
if CPage <= 0 then CPage = 1
'set the current page pointer
If numRecords > 0 Then
oRS.AbsolutePage = int(CPage)
End If
CRecord = 1
if not ors.bof or not ors.eof then
do
%>
<tr>
<td><font color="#333333" size="2" face="Verdana, Arial, Helvetica, sans-serif">
<% response.write "<a href=" & chr(34) & "forum.asp?AID=" & ors.fields("aid" & chr(34) &">" & ors.fields("Aname" & "</a>" %>
</font></td>
<td><font color="#333333" size="2" face="Verdana, Arial, Helvetica, sans-serif">
<% response.write ors.fields("aforumno" %>
</font></td>
</tr>
<%
ors.movenext
CRecord = CRecord + 1
loop until (ors.Eof) or (CRecord = oRS.pagesize)
end if
oRS=close
%>
</table>
Thanx for any help
Geo
--
the student will become the master