how to pass an access DB query onto *next* page? trouble with *next* and *previous* querystring code

Ask a Question related to ASP, Design and Development.

  1. #1

    Default Re: how to pass an access DB query onto *next* page? trouble with *next* and *previous* querystring code

    Don;t see any sign of any paging code is your snippets

    normally take this form

    Set rso = Server.CreateObject("ADODB.Recordset")
    rso.PageSize = iPageSize '<<<<<<< HOW MANY ITEMS PER PAGE
    rso.Open YOURSQL, conn , adOpenStatic, adLockReadOnly
    iPageCount = rso.PageCount ' <<<<<<<< TELLS US HOW MANY DB PAGES
    THERE ARE

    if rso.recordcount > 0 then

    rso.AbsolutePage = iPageCurrent '<<<<<<< THIS IS THE CURRENT DB PAGE
    YOU WANT TO SHOW
    set this
    based on your request.querystring("page")

    iRecordsShown = 0
    Do While iRecordsShown < iPageSize And Not rso.EOF

    ' do stuff here to show each record

    rso.movenext
    iRecordsShown = iRecordsShown + 1
    loop



    "cooldv" <mddv@hotmail.com> wrote in message
    news:d356c6c0.0308310446.6b6eccc2@posting.google.c om...
    > I am running a querry on an access database and have set the number of
    > records/page displayed at 20. if there are more than 20 records
    > returned, then 1st page will show the first 20, the next page will
    > show next 20 and so on....
    >
    > here is the trouble:
    > the count of total records displayed is correct and the first page is
    > displayed correctly. But when i click on *Next* to go to the next
    > page, all the records of the database get displayed (not the 2nd page
    > of records
    > from the query)
    >
    > obviously there is trouble in the *next* and the *previous*
    > querystring code. But what it is and what do i write to correct it?
    >
    > Someone did suggest a solution at the link below, but i didn't
    > understand it.
    >
    [url]http://groups.google.com/groups?dq=&hl=en&lr=&ie=UTF-8&threadm=OVOCG1KKDHA.1[/url]
    216%40TK2MSFTNGP11.phx.gbl&prev=/groups%3Fdq%3D%26num%3D25%26hl%3Den%26lr%3D
    %26ie%3DUTF-8%26group%3Dmicrosoft.public.inetserver.asp.genera l%26start%3D20
    0
    >
    > here is the code:
    >
    > <%
    > givenn=request.form("ftn")
    > familyn=request.form("ltn")
    > newman=request.form("fresher")
    > siti=request.form("cty")
    > prov=request.form("stt")
    > cantree=request.form("ctry")
    >
    > sqlstmt = "SELECT * from database WHERE firstnam like '%"& givenn &"%'
    > and lastnam like '%"& familyn &"%' and census like '%"& newman &"' and
    > city like '%"& siti &"%' and state like '%"& prov &"%' and country
    > like '%"& cantree &"%' ORDER by city"
    >
    >
    > If PageNo > 1 Then
    > <a href="query.asp?page=<%= PageNo - 1 %>"><< Prev</a>
    > End If
    >
    > If PageNo < TotalPages Then
    > <a href="query.asp?Page=<%= PageNo + 1 %>">Next >></a>
    > End If
    > %>
    >
    > any help appreciated

    only me Guest

  2. Similar Questions and Discussions

    1. Access Code Log In Page
      Here's what I'm attempting to do: I need to have a page that has a text box where someone can enter one word or a set numbers. Then when thye...
    2. Trouble accessing the MS Access 'MSysObjects' system table through an ASP page
      Earlier on this board, I got a solution from Ray (thanks again) on how to run a querry to see if a table exists and it works fine in Access. But...
    3. query a DB - pass the query to next page
      I am running a querry on an access database and have set the number of records/page displayed at 20. if there are more than 20 records returned,...
    4. Pass a querystring through <a href="mailto:xxxx .... using PHP variables
      I'm trying to send a link with a querystring as the body of an email message. My HTML syntax looks something like this: <a...
    5. Code Access to page
      There are a couple methods....first you could make use of some application events in global.asax such as Begin Request. However, I would...
  3. #2

    Default Re: how to pass an access DB query onto *next* page? trouble with *next* and *previous* querystring code

    hi onlyme,
    i did not show thw whole code thinking it was probably not related to
    the problem. here is the code:

    <%
    'Requesting the passed URL string ?Page= to identify the image we want
    PageNo = Request.QueryString("Page")
    IF isNumeric(PageNo) THEN
    PageNo = CLng(PageNo)

    END IF
    IF PageNo < 1 THEN PageNo = 1

    set conn = server.createobject("adodb.connection")
    ..... code for making DB connection

    givenn=request.form("ftn")
    familyn=request.form("ltn")
    newman=request.form("fresher")
    siti=request.form("cty")
    prov=request.form("stt")
    cantree=request.form("ctry")

    sqlstmt = "SELECT * from database WHERE firstnam like '%"& givenn &"%'
    and lastnam like '%"& familyn &"%' and census like '%"& newman &"' and
    city like '%"& siti &"%' and state like '%"& prov &"%' and country
    like '%"& cantree &"%' ORDER by city"

    Set rs = Server.CreateObject("ADODB.Recordset")
    rs.Open sqlstmt, conn, 3, 3

    TotalRecs = rs.recordcount
    rs.Pagesize=20
    TotalPages = cInt(rs.pagecount)
    rs.absolutepage=PageNo
    %>
    <%
    If PageNo > 1 Then
    %>
    <a href="query.asp?page=<%= PageNo - 1 %>">&lt;&lt; Prev</a>
    <%
    End If
    %>

    <%
    response.write "Page " & PageNo & " of " & TotalPages & " "
    DO WHILE iMenuCount <= TotalPages
    Response.Write "<a href=""query.asp?Page=" & iMenuCount
    IF PageNo = iMenuCount THEN
    Response.Write """ class=""selected"">" & iMenuCount & "</a>&nbsp;"
    ELSE
    Response.Write """ title=""Page " & iMenuCount & """>" & iMenuCount
    & "</a>&nbsp;"
    END IF
    iMenuCount = iMenuCount + 1
    Loop

    If PageNo < TotalPages Then
    %>
    <a href="query.asp?Page=<%= PageNo + 1 %>">Next &gt;&gt;</a>
    <%
    End If
    %>

    if i remove the query and just run the code, then all the pages in the
    DB get correctly displayed as 1 2 3 4 5 .... and each page works
    correctly.
    so it has to be the querystring function

    can you help? thanks in advance
    cooldv Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139