Paging through rs; the next page brings up full table.

Results 1 to 2 of 2

Thread: Paging through rs; the next page brings up full table.

  1. #1
    Marc Sazer Guest

    Default Paging through rs; the next page brings up full table.

    OK, I&#039ve got my database search working, and copied studiously how to page through the recordset. The first page of results looks fine, but when I hit the "next" button, the full table in the Access database which the rs was based on comes up.<BR>Help!<BR><BR>&#060;%@ LANGUAGE="VBSCRIPT" &#037;&#062;<BR>&#060;% Option Explicit &#037;&#062;<BR>&#060;!--#include File="ADOVBS.asp"--><BR>&#060;%<BR>Const NumPerPage = 3<BR><BR>Dim CurPage<BR>If Request.QueryString("CurPage") = "" then<BR>CurPage = 1 &#039We&#039re on the first page<BR>Else<BR>CurPage = Request.QueryString("CurPage")<BR>End If<BR><BR>Dim conn<BR>Set conn = Server.CreateObject("ADODB.Connection")<BR>conn.Co nnectionString = "DSN=147idir"<BR><BR>&#039Open a connection<BR>conn.Open <BR><BR>Dim rs <BR>Set rs = Server.CreateObject("ADODB.Recordset")<BR>rs.Curso rLocation = adUseClient<BR>rs.CacheSize = NumPerPage<BR><BR>Dim strSQL<BR>strSQL = "SELECT * FROM members WHERE (members.LASTNAME) LIKE &#039" & Request.QueryString("[Last Name]") & "%&#039 ORDER BY members.LASTNAME, members.FIRSTNAME "<BR>rs.Open strSQL, conn<BR><BR>rs.MoveFirst<BR>rs.PageSize = NumPerPage<BR>Dim TotalPages<BR>TotalPages = rs.PageCount<BR>rs.AbsolutePage = CurPage<BR>Dim count<BR>&#037;&#062;<BR>&#060;html><BR><BR>&#060; head><BR>&#060;title>LastName&#060;/title><BR>&#060;/head><BR><BR>&#060;body bgcolor="#FFCC00" vlink="#0000FF" topmargin="0"><BR>&#060;%<BR>Count = 0<BR>Do While Not rs.EOF And Count &#060; rs.PageSize<BR>Response.Write "&#060;font face=""tahoma,arial"" size=2>&#060;strong>" & rs("LastName")& "&#060;/strong>, " <BR>Response.Write "&#060;font face=""tahoma,arial"" size=2>" & rs("FirstName") <BR>Response.Write " " & rs("ProfName") <BR>Response.Write "......" & rs("Inst") <BR>Response.Write "<BR>Phone " & rs("Phone1") <BR>Response.Write " " & rs("Phone2") <BR>Response.Write " " & rs("Phone3")<BR>Response.Write "<BR>Service " & rs("Service") <BR>Response.Write "<BR>Pager " & rs("Pager")& "<BR>" <BR>Response.Write "&#060;a href=mailto:" & rs("Email") & ">" & rs("Email") & "&#060;/a>" <BR>Response.Write "&#060;hr>"<BR><BR>Count = Count + 1<BR>rs.MoveNext<BR>Loop<BR><BR>Response.Write("Pa ge " & CurPage & " of " & TotalPages & "&#060;P>")<BR><BR>if CurPage > 1 then<BR>Response.Write("&#060;INPUT TYPE=BUTTON VALUE=PREV ONCLICK=""document.location.href=&#039dirsearch2la st.asp?curpage=" & curpage - 1 & "&#039;"">")<BR>End If<BR><BR>if CInt(CurPage) &#060;> CInt(TotalPages) then<BR>Response.Write("&#060;INPUT TYPE=BUTTON VALUE=NEXT ONCLICK=""document.location.href=&#039dirsearch2la st.asp?curpage=" & curpage + 1 & "&#039;"">")<BR>End If<BR><BR>rs.Close<BR>Set rs = Nothing<BR>conn.Close<BR>Set conn = Nothing <BR>&#037;&#062;<BR>&#060;/body><BR>&#060;/html><BR>

  2. #2
    Amit Vaidya Guest

    Default RE: Paging through rs; the next page brings up full table.

    You can use the following code written byme. U&#039ll have to change DSN & query.<BR><BR><BR>html>&#060;head><BR>&#060;TITLE> dbtablepaged.asp&#060;/TITLE><BR>&#060;/head>&#060;body bgcolor="#FFFFFF"><BR>&#060;!--#INCLUDE VIRTUAL="adovbs.inc" --><BR><BR><BR>set conntemp=server.createobject("adodb.connection")<B R> conntemp.open "abc","abc","abc"<BR> &#039 DSN user password<BR> query="select * from books where title like &#039%TURBO&#039"<BR> <BR> mypage=request.querystring("whichpage")<BR>If mypage="" then<BR> mypage=1<BR>end if<BR>mypagesize=request.querystring("pagesize")<B R>If mypagesize="" then<BR> mypagesize=10<BR>end if<BR>set rstemp=Server.CreateObject("ADODB.Recordset")<BR>r stemp.cursorlocation=aduseclient<BR>rstemp.cachesi ze=5<BR>rstemp.open sqltemp,connectme<BR>rstemp.movefirst<BR>rstemp.pa gesize=mypagesize<BR>maxcount=cint(rstemp.pagecoun t)<BR>rstemp.absolutepage=mypage<BR>howmanyrecs=0< BR>howmanyfields=rstemp.fields.count -1<BR>response.write "Page " & mypage & " of " & maxcount & "<BR>"<BR>&#037;&#062;<BR>&#060;table border=1>&#060;tr><BR>&#060;% &#039Put Headings On The Table of Field Names<BR>for i=0 to howmanyfields &#037;&#062;<BR> &#060;td>&#060;b>&#060;%=rstemp(i).name &#037;&#062;&#060;/B>&#060;/TD><BR>&#060;%next&#037;&#062;<BR>&#060;/tr><BR>&#060;%do while not rstemp.eof and howmanyrecs&#060;rstemp.pagesize&#037;&#062;<BR>&# 060;tr><BR>&#060;%for i = 0 to howmanyfields&#037;&#062;<BR> &#060;td valign=top>&#060;%=rstemp(i)&#037;&#062;&#060;/td><BR>&#060;%next&#037;&#062;<BR>&#060;/tr><BR>&#060;%<BR>rstemp.movenext<BR>howmanyrecs=h owmanyrecs+1<BR>loop<BR>rstemp.close<BR>set rstemp=nothing<BR>&#037;&#062;<BR>&#060;/table>&#060;p><BR>&#060;%<BR>pad="0"<BR>scriptname =request.servervariables("script_name")<BR>for counter=1 to maxcount<BR> If counter>=10 then<BR> pad=""<BR> end if<BR> ref="&#060;a href=&#039" & scriptname & "?whichpage=" & counter<BR> ref=ref & "&pagesize=" & mypagesize & "&#039>" & pad & counter & "&#060;/a>"<BR> response.write ref & " "<BR> if counter mod 10 = 0 then<BR> response.write "<BR>"<BR> end if<BR>next<BR>&#037;&#062;<BR>&#060;/body>&#060;/html>

Posting Permissions

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