Hi
I've used the code below to naviagte through a Database using previous and next buttons. works fine except only one record per page is displayed. I'd like it to show the number I set in the interval per page i.e. 10 in this example
any help much appreciated
Ian
Set objCon = Server.CreateObject("ADODB.Connection")
objCon.CursorLocation = 3
objCon.ConnectionString = "Driver=SQL Server;Server=NAPLES;Database=FOI;User ID=aspgen;Password=genasp"
objCon.Open
Set objRS = Server.CreateObject("ADODB.RecordSet")
strSQL = "SELECT * FROM tblPublications_new"
set objRS=ObjCon.execute(strSQL)
'setting the number of records to display on each page
Interval = 10
'requesting the Starting Point from the page calling its self
'the querystring will be empty the first time the page is called
StartingPoint = request.queryString("StartingPoint")
'typecast the string to an integer
StartingPoint = CInt(StartingPoint)
'check to see if the querystring was empty
if StartingPoint = "" then
StartingPoint = 1
end if
'loop through the recordset to find the starting point
if StartingPoint > 1 then
for count=1 to StartingPoint
if objRS.EOF then
Exit For
else
objRS.movenext
end if
next
end if
'loop through the recordset from the startingpoint to the interval
for count=1 to Interval
if objRS.EOF then
exit for
else
b = "<table>"
b = b & "<tr>"
b = b & "<td>" & objRS("ID") & "</td>"
b = b & "<td>" & objRS("Title") & "</td>"
b = b & "</tr>"
b = b & "</table>"
objRS.movenext
end if
next
'displaying the previous page link when needed
if StartingPoint > 0 then 'checks to see if it needs to be displayed
b = b & " <font face='arial'><a href='main.asp?page=536&StartingPoint=" & StartingPoint-Interval & "'>Previous Page</a></font>"
end if
b = b & " "
'displaying the links for the pages
if objRS.RecordCount Mod Interval = 0 then
'displays pages if there is an evenly divisible number of records per page
'eg. if there are 50 records and 10 per page, 5 pages
for I=0 to (objRS.RecordCount/Interval)-1
if Interval*I = StartingPoint then
'displays the current page link as red
b = b & " <font face='arial' color='red'><b><u>" & I+1 & "</u></b> </font>"
else
'displays the page links
b = b & " <font face='arial'><a href='main.asp?page=536&StartingPoint=" & Interval*I & "'>" & I+1 & "</a> </font>"
end if
next
else
'displays pages if there is not an evenly divisible number of records per page
'eg. if there are 52 records and 10 per page, 6 pages
for I=0 to (objRS.RecordCount/Interval)
if Interval*I = StartingPoint then
'displays the current page link as red
b = b & " <font face='arial' color='red'><b><u>" & I+1 & "</u></b> </font>"
else
'displays the page links
b = b & " <font face='arial'><a href='main.asp?page=536&StartingPoint=" & Interval*I & "'>" & I+1 & "</a> </font>"
end if
next
end if
b = b & " "
'Displays the link for the Next Page if there is a next page to come
if StartingPoint+Interval < objRS.Recordcount then
b = b & " <font face='arial'><a href='main.asp?page=536&StartingPoint=" & StartingPoint+Interval & "'>Next Page</a></font>"
end if
objCon.Close
Set objCon = Nothing
objBODY = b
I've used the code below to naviagte through a Database using previous and next buttons. works fine except only one record per page is displayed. I'd like it to show the number I set in the interval per page i.e. 10 in this example
any help much appreciated
Ian
Set objCon = Server.CreateObject("ADODB.Connection")
objCon.CursorLocation = 3
objCon.ConnectionString = "Driver=SQL Server;Server=NAPLES;Database=FOI;User ID=aspgen;Password=genasp"
objCon.Open
Set objRS = Server.CreateObject("ADODB.RecordSet")
strSQL = "SELECT * FROM tblPublications_new"
set objRS=ObjCon.execute(strSQL)
'setting the number of records to display on each page
Interval = 10
'requesting the Starting Point from the page calling its self
'the querystring will be empty the first time the page is called
StartingPoint = request.queryString("StartingPoint")
'typecast the string to an integer
StartingPoint = CInt(StartingPoint)
'check to see if the querystring was empty
if StartingPoint = "" then
StartingPoint = 1
end if
'loop through the recordset to find the starting point
if StartingPoint > 1 then
for count=1 to StartingPoint
if objRS.EOF then
Exit For
else
objRS.movenext
end if
next
end if
'loop through the recordset from the startingpoint to the interval
for count=1 to Interval
if objRS.EOF then
exit for
else
b = "<table>"
b = b & "<tr>"
b = b & "<td>" & objRS("ID") & "</td>"
b = b & "<td>" & objRS("Title") & "</td>"
b = b & "</tr>"
b = b & "</table>"
objRS.movenext
end if
next
'displaying the previous page link when needed
if StartingPoint > 0 then 'checks to see if it needs to be displayed
b = b & " <font face='arial'><a href='main.asp?page=536&StartingPoint=" & StartingPoint-Interval & "'>Previous Page</a></font>"
end if
b = b & " "
'displaying the links for the pages
if objRS.RecordCount Mod Interval = 0 then
'displays pages if there is an evenly divisible number of records per page
'eg. if there are 50 records and 10 per page, 5 pages
for I=0 to (objRS.RecordCount/Interval)-1
if Interval*I = StartingPoint then
'displays the current page link as red
b = b & " <font face='arial' color='red'><b><u>" & I+1 & "</u></b> </font>"
else
'displays the page links
b = b & " <font face='arial'><a href='main.asp?page=536&StartingPoint=" & Interval*I & "'>" & I+1 & "</a> </font>"
end if
next
else
'displays pages if there is not an evenly divisible number of records per page
'eg. if there are 52 records and 10 per page, 6 pages
for I=0 to (objRS.RecordCount/Interval)
if Interval*I = StartingPoint then
'displays the current page link as red
b = b & " <font face='arial' color='red'><b><u>" & I+1 & "</u></b> </font>"
else
'displays the page links
b = b & " <font face='arial'><a href='main.asp?page=536&StartingPoint=" & Interval*I & "'>" & I+1 & "</a> </font>"
end if
next
end if
b = b & " "
'Displays the link for the Next Page if there is a next page to come
if StartingPoint+Interval < objRS.Recordcount then
b = b & " <font face='arial'><a href='main.asp?page=536&StartingPoint=" & StartingPoint+Interval & "'>Next Page</a></font>"
end if
objCon.Close
Set objCon = Nothing
objBODY = b