Click to See Complete Forum and Search --> : Asp Classic database paging Issue. Help Help Help plsssssssssssss!!!


1180gibok
07-10-2009, 07:22 AM
Hello friends, pls can any one help to have a look at the code below for debugging. It is working partially but not fully. The problem is in the paging function. after the first page is returned when users click on next, it does not show, it generates error. Can any one help pls with your expertise:
<%
u_search=request.form("u_search")
u_exp=request.form("u_exp")
u_id=request.querystring("u_id")

' Grabs the contstant for cursorlocation

p=request.form("p")
' Check the value of p (page) and make sure it is not null
' If a null value is found then 1 is put in its place
if p = "" then
p=1
end if

'Checks to see if the user has submitted a search or
'clicked a hyperlink
if u_search <> "" or u_id <> "" then
accessdb="mapntl"
cn="driver={Microsoft Access Driver (*.mdb)};"
cn=cn & "dbq=" & server.mappath(accessdb)
set rs = server.createobject("ADODB.Recordset")

sql = "select * from tblmapntl where "& u_exp &" like '%%" &u_search &"%%' order by BusinessName asc "
'sql

' ***********************************
' Implements the value from adovbs.inc
'rs.cursorlocation=aduseclient
'rs.CursorLocation = adUseClient
rs.CursorType = adOpenStatic
'rs.CursorLocation = adUseClient
'rs.CursorType = adOpenForwardOnly
'rs.LockType = adLockReadOnly
' *************************************
rs.cachesize=5
rs.open sql,cn,3,1
if not rs.eof then
g_search="obs found"
rs.movefirst

' Sets the number of observations per page to a max of four
rs.pagesize=10
maxcount=cint(rs.pagecount)
rs.absolutepage=p
%>

<%do while not rs.eof and numofobs<rs.pagesize%>
<style type="text/css">
<!--
.style1 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
}
.style3 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 14px;
color: #FF3300;
}
.style4 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-weight: bold;
font-size: 12px;
}
-->
</style>

<table width="749" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutDefaultTable-->
<tr>
<td width="331" height="319" valign="top"><p><strong><span class="style3"><%= rs("BusinessType") %>(<%= rs("Businesscategory1") %>) </span></strong></p>
<p class="style1"><strong><%= rs("BusinessName") %></strong> <%= rs("Xcontact") %> <a href="<%= rs("xwebsite") %>">
<%= rs("xwebsite") %></a> <br />
<%= rs("BusinessAddress") %><br />
</p>
<p class="style1"><%= rs("Bizinfo") %> Product includes:</p>
<ul type="disc" class="style1">
<li><%= rs("producttype1") %></li>
<li><%= rs("producttype2") %></li>
<li><%= rs("producttype3") %></li>
</ul>

<p class="style1"><a href="<%= rs("map_location") %>" onclick="MM_openBrWindow('&lt;a href=&quot;<%= rs("map_location") %>&quot;&gt; &lt;/a&gt; ','','scrollbars=yes,width=400,height=150')">
<img src="images/mapntlm.jpg" width="112" height="63"><%= rs("map_view") %></a> </p>
<p class="style1">&nbsp;</p></td>
<td width="418">&nbsp;</td>
</tr>

<%
rs.movenext
' Counts the number of observations in the current page
numofobs=numofobs+1
loop

%>
</table>

<form>
<input type="button" value="Print" Onclick="print()" ;>
</form>

<form method='post' action='<%= request.servervariables("script_name")%>'>
<input type = "hidden" name="u_search" value="<%= u_search %>">
<select name='p' size='1'>
<%
' Starts loop from one to the maximum number of pages
for counter=1 to cint(rs.pagecount)
%>
<option<%
' This will select the current page in the dropdown menu
if cint(p) = cint(counter) then
response.write " selected "
end if
%> value="<%= counter %>">Page <%= counter %> of <%= cint(rs.pagecount) %></option>
<% next %>
</select> <input type="submit" value="Go"></p>
</form>
<br>
<%
if p <> 1 then
%>
<form method='post' action='<%= request.servervariables("script_name")%>'>
<input type = "hidden" name="p" value="<%= p-1 %>">
<input type = "hidden" name="u_search" value="<%= u_search %>">
<input type = "submit" value="&lt;">&nbsp;Previous Page
</form>
<% end if %>
<%
if cint(p) < cint(rs.pagecount) then
%>
<form method='post' action='<%= request.servervariables("script_name")%>'>
<input type = "hidden" name="u_search" value="<%= u_search %>">
<input type = "hidden" name="p" value="<%= p+1 %>">
Next Page&nbsp;<input type = "submit" value="&gt;">
</form>
<% end if %>
<p>
<%= numofobs &" searched records displayed this page<br>" %>
</p>
<%
end if
end if
%>
<%
'Check to see if the search resulted in observations found
'if not then display a message that states no results found
if g_search <> "obs found" then
response.write "Refine your search! Please saarch using the catagories listed <i>"& u_search &"</i><br>"
end if %>
<br><br>

<form action="paging_tst.asp" method="post">

<input type="text" name="u_search" value="<%= u_search %>">
&nbsp;
<select size="1" name="u_exp">
<option selected value="businesstype">Business Category</option>
<option value="businessname">Business Name</option>
<option value="locate">Location</option>
</select>
&nbsp;
<input type="submit" value="Search">

</form>

Emefa
07-16-2009, 01:04 PM
I didn't have enough time to look through your code and because you did not specify which error message you were getting, it is hard to tell.

I have included an all-in-one tutorial I developed sometime back with alternative row, paging and record count in Classic ASP.
Please see if this fits your need or adjust to fit.
This works 100% for paging.