Recordset Paging - Not Showing records on next page

Recordset Paging - Not Showing records on next page

am 26.06.2007 10:39:18 von Infused

When I use the next button no records show up on the next page...
I've been going over this for half a day and can't figure it out. Any
help would be greatly appreciated!

<%@ Language=VBScript%>
<%Option Explicit%>
<%Response.Expires=0%>

<%
Const intPageSize = 10
Dim intCurrentPage, intTotalPages, intI
Dim sClass
Dim rs, sCN, sSql, sDbFilePath
Dim dLNG, dLAT, sZip
Dim bViewList: bViewList = false


Set rs = Server.CreateObject("ADODB.Recordset")
rs.CursorLocation = 3
rs.CursorType = 3
rs.CacheSize = intPageSize
sDbFilePath = Server.MapPath("zip.mdb")
sCN = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & sDbFilePath &
";Persist Security Info=False"

If len(trim(Request.Form("zip"))) = 5 and
isnumeric(Request.Form("zip")) Then
sZip = Request.Form("zip")
SetCoordinates sZip
Set rs = Getmains(Request.Form("distance"), dLNG, dLAT)
bViewList = (not rs.EOF)
End If


'=========================================================== ========
Function Getmains(dRadius, dLNG, dLAT)

Dim rsTemp, sSql
Set rsTemp = Server.CreateObject("ADODB.Recordset")

' **SQL Server vesion - use ACOS()**
' sSql = "SELECT name, phone, addr1, city, state, zip " & _
' "FROM main " & _
' "WHERE zip in ( SELECT ZIP_CODE FROM zip "& _
' "WHERE @radius > 3959 * ACOS(SIN(@lat/ 57.3) *
SIN(LAT/ 57.3) + " & _
' "COS(@lat/ 57.3) *
COS(LAT/ 57.3) * " & _
' "COS((LNG/ 57.3) -
(@lng/ 57.3))) ) " & _
' "ORDER BY name"

' **Access vesion**
sSql = "SELECT id, name, phone, addr1, city, state, zip " & _
"FROM main " & _
"WHERE zip in ( SELECT ZIP_CODE FROM zip "& _
"WHERE @radius > 3959 * ATN( SQR(1 - (SIN(@lat/
57.3) * SIN(LAT/ 57.3) + " & _
"COS(@lat/
57.3) * COS(LAT/ 57.3) * " & _
"COS((LNG/
57.3) - (@lng/ 57.3))) ^2 ) /" & _
"(SIN(@lat/ 57.3) * SIN(LAT/ 57.3) + "
& _
"COS(@lat/
57.3) * COS(LAT/ 57.3) * " & _
"COS((LNG/
57.3) - (@lng/ 57.3))) ) ) " & _
"ORDER BY name"

sSql = Replace(sSql, "@radius",dRadius)
sSql = Replace(sSql, "@lng",dLNG)
sSql = Replace(sSql, "@lat",dLAT)
rsTemp.Open sSql, sCN, 3, 3
Set Getmains = rsTemp

End Function
'=========================================================== ========
Sub SetCoordinates(sZip)

Dim rsTemp, sSql
Set rsTemp = Server.CreateObject("ADODB.Recordset")

sSql = "SELECT LAT, LNG FROM zip WHERE ZIP_CODE = ':1'"
sSql = Replace(sSql, ":1",sZip)
rsTemp.Open sSql, sCN
If not rsTemp.EOF Then
dLAT = rsTemp("LAT")
dLNG = rsTemp("LNG")
End If
Set rsTemp = Nothing

End Sub
'=========================================================== ========
'Function CreateMapQuestURL(street, city, state, zip)
'
' Dim sStreet, sCity
'
' sStreet = Replace(Trim(street), " ", "+")
' sCity = Replace(Trim(city), " ", "+")
'
' CreateMapQuestURL = "http://www.mapquest.com/maps/map.adp?" & _
' "country=US&" & _
' "address=" & sStreet & "&" & _
' "city=" & sCity & "&" & _
' "state=" & state & "&" & _
' "zipcode=" & zip
'End Function

'=========================================================== =======
'Function CreateMapBlastURL(name, street, city, state, zip)
'
' Dim sStreet, sCity, sName
'
' sStreet = Replace(Trim(street), " ", "+")
' sCity = Replace(Trim(city), " ", "+")
' sName = Replace(Trim(name), " ", "+")
'
' CreateMapBlastURL = "http://www.mapblast.com/mblast/map.mb?" & _
' "IC=" & sName & "&" & _
' "AD2=" & sStreet & "&" & _
' "AD3=" & sCity & "&" & _
' "AD3=" & state & "&" & _
' "AD3=" & zip & "&" & _
' "CMD=GEO"
'End Function
'=========================================================== ========
%>

<%
Response.Write("Server Variables: ")
Response.Write(Request.ServerVariables("ALL_RAW"))

If Request.ServerVariables("CONTENT_LENGTH") = 0 then
intCurrentPage = 1
Else
intCurrentPage = CInt(Request.Form("CurrentPage"))
Select Case Request.Form("Submit")
Case "Previous"
intCurrentPage = intCurrentPage - 1
Case "Next"
intCurrentPage = intCurrentPage + 1
End Select
End If
%>








height="97">


Search by Zipcode



















ZIP Distance name=submit1>




 <%If bViewList Then%>











<%
rs.PageSize = intPageSize
'Response.Write(intPageSize)

If Not(rs.EOF) Then
intCurrentPage = rs.AbsolutePage

'Response.Write("AbsolutePage = ")
'Response.Write(rs.AbsolutePage)

intTotalPages = rs.PageCount
%>
<%
If sClass <> "shade" Then
sClass = "shade"
Else
sClass = ""
End If
%>
<% For intI = 1 to rs.PageSize %>









<%rs.MoveNext
If rs.EOF Then Exit For
Next

rs.close
set rs = nothing%>
<% End If %>

NAME PHONE ADDRESS CITY STATE ZIP
"><%=rs("name") & ""%> a> <%=rs("phone") & ""%> <%=rs("addr1") & ""%> <%=rs("city") & ""%> <%=rs("state") & ""%> <%=rs("zip") & ""%>


<%= intCurrentPage %> of <%=intTotalPages %>


"
method="POST">
Script Name:
<% Response.Write(Request.ServerVariables("SCRIPT_NAME")) %>

<%
If intCurrentPage > 1 Then %>

<% End If
If intCurrentPage <> intTotalPages Then %>

<% End if %><% End IF%>


Re: Recordset Paging - Not Showing records on next page

am 27.06.2007 10:45:43 von Daniel Crichton

AnxietyAnswers wrote on Tue, 26 Jun 2007 01:39:18 -0700:

> When I use the next button no records show up on the next page...
> I've been going over this for half a day and can't figure it out. Any
> help would be greatly appreciated!

>

"
> method="POST">
> Script Name:
> <% Response.Write(Request.ServerVariables("SCRIPT_NAME")) %>
>
> <%
> If intCurrentPage > 1 Then %>
>
> <% End If
> If intCurrentPage <> intTotalPages Then %>
>
> <% End if %><% End IF%>
>


>
>

In the above form you don't have any of the fields required to fill the
query with values for the ZIP being looked for, so your query is running
with different data than the initial request, and likely bringing back an
empty recordset which is why you get no results. You'll need to add the ZIP
code as a hidden field in the form so it gets resubmitted with the
Previous/Next button.

Also I can't see anywhere in the code I trimmed out that sets the page to
view - you're reading the AbsolutePage value into the intCurrentPage
variable, rather than setting AbsolutePage to the page you want to view, so
even if you'd been passing the ZIP in the second form you'll just be showing
page 1 of the results again no matter which button is pressed.

Dan

Re: Recordset Paging - Not Showing records on next page

am 27.06.2007 18:40:20 von Infused

On Jun 27, 1:45 am, "Daniel Crichton" wrote:
> AnxietyAnswers wrote on Tue, 26 Jun 2007 01:39:18 -0700:
>
>
>
>
>
> > When I use the next button no records show up on the next page...
> > I've been going over this for half a day and can't figure it out. Any
> > help would be greatly appreciated!
> >

"
> > method="POST">
> > Script Name:
> > <% Response.Write(Request.ServerVariables("SCRIPT_NAME")) %>
> >
> > <%
> > If intCurrentPage > 1 Then %>
> >
> > <% End If
> > If intCurrentPage <> intTotalPages Then %>
> >
> > <% End if %><% End IF%>
> >

> >
> >
>
> In the above form you don't have any of the fields required to fill the
> query with values for the ZIP being looked for, so your query is running
> with different data than the initial request, and likely bringing back an
> empty recordset which is why you get no results. You'll need to add the ZIP
> code as a hidden field in the form so it gets resubmitted with the
> Previous/Next button.

Absolutely right thanks Dan I added the hidden fields in the form and
now I'm getting the intial recordset in next page. Thanks!

> Also I can't see anywhere in the code I trimmed out that sets the page to
> view - you're reading the AbsolutePage value into the intCurrentPage
> variable, rather than setting AbsolutePage to the page you want to view, so
> even if you'd been passing the ZIP in the second form you'll just be showing
> page 1 of the results again no matter which button is pressed.
>
> Dan- Hide quoted text -
>
> - Show quoted text -

I kept getting the error

ADODB.Recordset error '800a0cb3'
Current Recordset does not support bookmarks. This may be a limitation
of the provider or of the selected cursortype.

when I had the abolsultepage = intcurrentpage the right way around

and thought I had the cursortype set the right way but when I checked
it was coming up with cursortype = 0

I've got everything fixed and it's working perfect now thank you so
very much for your help I really appreciate it!!!

Jon

Re: Recordset Paging - Not Showing records on next page

am 28.06.2007 08:52:09 von Daniel Crichton

Infused wrote on Wed, 27 Jun 2007 09:40:20 -0700:

> I've got everything fixed and it's working perfect now thank you so
> very much for your help I really appreciate it!!!

Glad to hear it's all working

Dan