ASP page turner

Hello experts,

I am trying to do a page turner for an app i am working, on, i had a bit of code, but i have had to change it to suit my site, but now unfortunately, it no longer works properly. The code was writtent to serach throughtthe database and display all records but i amedned the code to dispaly records where critera = variable. This is the problem I have;

if i get for example;

page << 1 of 3 >> for a set of records. and then clikck next >> to go to next record, it then becomes page << 2 of 7 >>.

CODESS BELOW.

ORIGINAL CODE:

Function owPreserve(owVariable,owDefault)
      owTemp = Request.QueryString(owVariable)
            'If the querystring contains any data it is counted as a variable change, if not the old variable is taken from the session or the default assigned
            If Len(owTemp) = 0 Then
                  If Len(Session("user_"&owVariable)) > 0 Then
                        owTemp = Session("user_"&owVariable)
                  Else
                        owTemp = owDefault
                  End If
            End If
      Session("user_"&owVariable) = owTemp
      owPreserve = owTemp
End Function

viewRange = owPreserve("range",1)
varCurPage = owPreserve("page",1)
%>

      <%
globalPageSize = 5
oRs.cursorlocation=3
oRs.cachesize=5

If PageAction = "results" Then
      'Builds the magical search sql query
Else      
      Sql = "SELECT * FROM [product] WHERE [range]="&viewRange&" AND [active]"
End If
oRs.Open Sql, oCn

If Not oRs.Eof Then
      oRs.MoveFirst
       oRs.PageSize = globalPageSize      

      maxpages = cint(oRs.pagecount)
      
      If cint(varCurPage) > maxpages Then
            varCurPage = 1
      End If
      
      oRs.AbsolutePage = varCurPage
      nexpage = varCurPage + 1
      prepage = varCurPage - 1
      Else
            varCurPage = 1
      End If

Do While Not oRs.Eof And Not curRecord = oRs.PageSize

tId = oRs("id")
tTitle = oRs("title")
tFeatures = oRs("features")
tImage = oRs("image")
%>

<table align="center" border="0" cellspacing="10" cellpadding="0">
<tr>
    <td class="PageTurner" colspan="5"><%if cint(varCurPage) > 1 then
                        %>                        
                              <a href="index.asp?page=<%=prepage%>&showtype=<%=showtype%>"><img src="../resources/images/interactive/prevena.gif" width="15" height="14" border="0" align="absmiddle"></a>
                              <%
                        else
                        %>
                              <img src="../resources/images/interactive/prevdis.gif" width="15" height="14" align="absmiddle">
                              <%
                        end if
                        %>
                          Page <%=varCurPage%> of <%If maxpages < 1 Then%>1<%else%><%=maxpages%><%end if%>
                          <%
                        if not cint(varCurPage) < cint(maxpages) then
                        %>
                          <img src="../resources/images/interactive/nextdis.gif" width="15" height="14" align="absmiddle">
                          <%
                        else
                        %>
                          <a href="index.asp?page=<%=nexpage%>&showtype=<%=showtype%>"><img src="../resources/images/interactive/nextena.gif" width="15" height="14" border="0" align="absmiddle"></a>
                          <%
                        end if%></td>
      </tr>
</table>




I HAVE CHANGED THIS TO BECOME THE FOLLOWING;-


<%
viewRange = cint(Request.Form("CID")) <----- I am passing a value to this from a previous page.
%>

Function owPreserve(owVariable,owDefault)
      owTemp = Request.QueryString(owVariable)
            'If the querystring contains any data it is counted as a variable change, if not the old variable is taken from the session or the default assigned
            If Len(owTemp) = 0 Then
                  If Len(Session("user_"&owVariable)) > 0 Then
                        owTemp = Session("user_"&owVariable)
                  Else
                        owTemp = owDefault
                  End If
            End If
      Session("user_"&owVariable) = owTemp
      owPreserve = owTemp
End Function

'viewRange = owPreserve("range",1)<------ commented out as causes the same records to be displayed all the time
varCurPage = owPreserve("page",1)
%>



<%
globalPageSize = 5
rsQuery.cursorlocation=3
rsQuery.cachesize=5

If viewRange = 0 Then
   Sql = "SELECT * FROM [product]"
Else
If PageAction = "results" Then
      'Builds the magical search sql query
Else      
      Sql = "SELECT * FROM [product] WHERE [range]="&viewRange&" AND [active]"
End If
End If
rsQuery.Open Sql, Con

If Not rsQuery.Eof Then
      rsQuery.MoveFirst
       rsQuery.PageSize = globalPageSize      

      maxpages = cint(rsQuery.pagecount)
      
      If cint(varCurPage) > maxpages Then
            varCurPage = 1
      End If
      
      rsQuery.AbsolutePage = varCurPage
      nexpage = varCurPage + 1
      prepage = varCurPage - 1
      Else
            varCurPage = 1
      End If

Do While Not rsQuery.Eof And Not curRecord = rsQuery.PageSize

tId = rsQuery("id")
tTitle = rsQuery("title")
tFeatures =

 rsQuery("features")
tImage = rsQuery("image")
%>

<%
      rsQuery.MoveNext
      curRecord = curRecord + 1
Loop
rsQuery.Close
%>
<table align="center" border="0" cellspacing="10" cellpadding="0">
<tr>
    <td class="PageTurner" colspan="5"><%if cint(varCurPage) > 1 then
                        %>                        
                              <a href="products.asp?page=<%=prepage%>&showtype=<%=showtype%>"><img src="../resources/images/interactive/prevena.gif" width="15" height="14" border="0" align="absmiddle"></a>
                              <%
                        else
                        %>
                              <img src="../resources/images/interactive/prevdis.gif" width="15" height="14" align="absmiddle">
                              <%
                        end if
                        %>
                          Page <%=varCurPage%> of <%If maxpages < 1 Then%>1<%else%><%=maxpages%><%end if%>
                          <%
                        if not cint(varCurPage) < cint(maxpages) then
                        %>
                          <img src="../resources/images/interactive/nextdis.gif" width="15" height="14" align="absmiddle">
                          <%
                        else
                        %>
                          <a href="products.asp?page=<%=nexpage%>&showtype=<%=showtype%>"><img src="../resources/images/interactive/nextena.gif" width="15" height="14" border="0" align="absmiddle"></a>
                          <%
                        end if%></td>
      </tr>
</table>



Thank you

 
LVL 4
claracruzAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

muzzy2003Commented:
Change:

viewRange = cint(Request.Form("CID")) <----- I am passing a value to this from a previous page.

to

viewRange = cint(Request("CID")) <----- I am passing a value to this from a previous page.

and then change:

                          <a href="products.asp?page=<%=prepage%>&showtype=<%=showtype%>"><img src="../resources/images/interactive/prevena.gif" width="15" height="14" border="0" align="absmiddle"></a>

and similar links to:

                          <a href="products.asp?page=<%=prepage%>&showtype=<%=showtype%>&CID=<%=viewRange>"><img src="../resources/images/interactive/prevena.gif" width="15" height="14" border="0" align="absmiddle"></a>
0
muzzy2003Commented:
Basically, the viewRange was passed in the QueryString originally, but you have changed this to post from a form. When you then navigate between the pages, passing data by QueryString, you lose this value. I have put it in, and allowed it to be resolved either from the Form or the QueryString.
0
claracruzAuthor Commented:
hello, thanks for that, but now i et the following error;-

Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.
/shop-gs/products.asp, line 62

rsQuery.AbsolutePage = varCurPage<-------Line 62.
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

muzzy2003Commented:
Try rsQuery.AbsolutePage = CInt(varCurPage)

Any better?
0
claracruzAuthor Commented:
still getting

Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.
/shop-gs/products.asp, line 62
0
muzzy2003Commented:
Do you get this error when you first go to the page, or when you click on one of the page links?
0
claracruzAuthor Commented:
when i go to the first page
0
muzzy2003Commented:
That's before you hit the code I've changed then. Are you sure you're using the right URL? Has your session timed out?
0
claracruzAuthor Commented:
no it hasn't..
0
muzzy2003Commented:
Just a thought. You give the top of your page as:

<%
viewRange = cint(Request.Form("CID")) <----- I am passing a value to this from a previous page.
%>

Function owPreserve(owVariable,owDefault)
     owTemp

Is this correct? I don't think the %> should be in there, and perhaps it isn't, but I'm just trying to eliminate everything I can.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
claracruzAuthor Commented:
i have changed the entire code to the so now works fine!!!! but thanks for all the help
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.