Hello,
Thanks for looking at this. I have stripped my code down to hopefully make this easy to read.
Basically i am selecting data from a SQL Express database, where idstatus = a number. The results will vary but most times there will be several pages worth of data, of which i only want to display 3 rows per page.
What i need to be able to do is move back and forth through the records using the navigation in my code, i am using using oRs.PageSize. The problem i have is, i am not getting any errors with the code below, it is also displays the correct number of records that the query pulls and the navigation show x pages and click next and back and it shows page 2 of 6 etc, but the records that are displayed don't move.... Also NumPerPage = 3 is not working as its displaying 10 records.. So, page one through to 7 for example display the same results..
Any ideas, please let me know.
Thanks
Thanks for looking at this. I have stripped my code down to hopefully make this easy to read.
Basically i am selecting data from a SQL Express database, where idstatus = a number. The results will vary but most times there will be several pages worth of data, of which i only want to display 3 rows per page.
What i need to be able to do is move back and forth through the records using the navigation in my code, i am using using oRs.PageSize. The problem i have is, i am not getting any errors with the code below, it is also displays the correct number of records that the query pulls and the navigation show x pages and click next and back and it shows page 2 of 6 etc, but the records that are displayed don't move.... Also NumPerPage = 3 is not working as its displaying 10 records.. So, page one through to 7 for example display the same results..
Any ideas, please let me know.
Thanks
Code:
<%@ LANGUAGE = VBScript %>
<!--#include file="includes/connection.asp"-->
<%
'Set how many records per page we want
Const NumPerPage = 3
'Retrieve what page we're currently on
Dim CurPage
If Request.QueryString("CurPage") = "" then
CurPage = 1
Else
CurPage = Request.QueryString("CurPage")
End If
'Explicitly Create a recordset object
Dim oRs
Set oRs = Server.CreateObject("ADODB.Recordset")
'Set the cache size = to the # of records/page
oRs.CacheSize = NumPerPage
qry = "SELECT * FROM wce_contact WHERE IDSTATUS LIKE '"&"%"&("333")&"%"&"'"' WHERE " &(qryresult)& " "& (orderby)
response.write(qry)
'response.end
oRs.Open qry, connStr,3,3
oRs.MoveFirst
oRs.PageSize = NumPerPage
'Count all the records in the DB
Dim NumRecords
NumRecords = oRs.RecordCount
'Get the max number of pages
Dim TotalPages
TotalPages = oRs.PageCount
'Set the absolute page
oRs.AbsolutePage = CurPage
'Counting variable for our recordset
Dim count
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>WiredContact Enterprise</title>
</head>
<body bgcolor="#F7EFCE" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<form name="mailerlookup" method="post" action="MailerLookup.asp">
<table width="55%" border="0" class="query" cellspacing="2" cellpadding="2">
<tr>
<td colspan="2" align="center"><input type="submit" value="Run Query" /></td>
</tr>
<tr>
<td colspan="4"><hr /></td>
</tr>
</table>
</form>
<form name="results" method="post" onSubmit="openTarget(this, 'width=400,height=400,resizable=1,scrollbars=1'); return true;" target="newpopup" action="AttachToMailer.asp?type=SearchMailers">
<table width="90%" class="results">
<tr>
<td colspan="6"> </td>
</tr>
<tr>
<td width="2%"> </td>
<td width="15%"><h6>Contact</h6></td>
<td width="10%"><h6>Rooms From</h6></td>
<td width="10%"><h6>Ref Num</h6></td>
<td width="10%"><h6>Price from</h6></td>
<td width="10%"><h6>Price</h6></td>
</tr>
<%
Set oRs = connStr.Execute(qry)
%>
<tr>
<td width="25%"><b><%=(NumRecords)%> record(s)</b></td>
<td width="25%"><b><%=(TotalPages)%> pages</b></td>
<td colspan="3" width="50%"><b>Current page <%=(CurPage)%></b></td>
</tr>
<tr>
<td colspan="5"><hr /></td>
</tr>
</tr>
<%If CurPage > 1 Then%>
<tr>
<td colspan="2"><b><a href="MailerLookup.asp?curpage=<%=(curpage) - 1%>"><-- Prev Page</a></b></td>
<%
End If
If CInt(CurPage) <> CInt(TotalPages) Then
%>
<td colspan="3"><b><a href="MailerLookup.asp?curpage=<%=(curpage) + 1%>">Next Page --></a></b></td>
</tr>
<%
End If
%>
<%
Count = 0
Do While Not oRs.EOF And Count < oRs.PageSize
strBGcolour = "#D0D0D0"
Response.Write("<tr><td bgcolor='" & strBGColour & "'><input type='checkbox' name='uniqueid' value='" & oRs("uniqueid") & "' /></td><td bgcolor='" & strBGColour & "'>" & oRs("contact") & "</td><td bgcolor='" & strBGColour & "'>" & oRs("Rooms_From") & "</td><td bgcolor='" & strBGColour & "'>" & oRs("idstatus") & "</td><td bgcolor='" & strBGColour & "'>" & oRs("price_from") & "</td><td bgcolor='" & strBGColour & "'>" & oRs("price") & "</td></tr>")
Count = Count + 1
oRs.MoveNext
Loop
%>
</table>
</form>
</body>
</html>
<%
'End If
%>