RecordSet problems - maximum records on a page

Results 1 to 2 of 2

Thread: RecordSet problems - maximum records on a page

  1. #1
    Join Date
    Dec 1969

    Default RecordSet problems - maximum records on a page

    I have a page which displays a series of records from a database. I can set a maximum number of records per page. The only problem is I would like to be able to alter it slightly so that if a maximum number of characters have been reached it may just display fewer records on that page instead.<BR><BR>I&#039;ve been able to do it, but I can&#039;t get it to add the &#039;next&#039; and &#039;previous&#039; links because it currently iterates through the entire recordset but it just doesn&#039;t display the extra records. But I can&#039;t figure out a way to get it working correctly even though I understand the problem<BR><BR>can anyone see some rephrasing that could be done to the following to get it working right?<BR><BR>[%<BR>MaxMailNo = 6 &#039; maximum no of records per page<BR><BR>PageNo=Request("PgNo")<BR>if PageNo="" then<BR>PageNo=1<BR>else<BR>PageNo=cint(PageNo)<BR >end if<BR><BR>Count=0<BR>FinalCount=Count<BR>OpenAddre ss con<BR>SQL = &#039;the sql statement here<BR><BR>Set rs = Server.CreateObject("ADODB.Recordset")<BR>rs.Open SQL,con,3,3<BR>If rs.EOF Then<BR>%]<BR><BR>&#039;display HTML saying that no records could be found<BR><BR>[%<BR>Else<BR>rs.PageSize = MaxMailNo<BR>LastPage = rs.PageCount<BR>rs.AbsolutePage = PageNo<BR><BR>for i = 1 to rs.PageSize<BR><BR>News_ID = rs("News_ID")<BR>News_Title = rs("News_Title")<BR>News_Article = rs("News_Article")<BR>News_Author = rs("News_Author")<BR>News_Time = rs("News_Time")<BR>News_Date = rs("News_Date")<BR><BR>News_Article = Replace(Server.HTMLEncode(News_Article), vbCrLf, "[br]")<BR><BR>if FinalCount &#060; 10 then<BR>%]<BR><BR>&#039;HTML code displaying the record<BR><BR>[%<BR>end if<BR><BR>rs.PageSize=2<BR>Count = Len(News_Article)<BR>FinalCount=FinalCount+Count<B R><BR>rs.MoveNext<BR>if rs.EOF then exit for<BR>Next<BR>rs.close<BR>Set rs = Nothing<BR>con.close<BR>set con = Nothing<BR>%]<BR><BR><BR>[% if PageNo &#062; 1 then %]<BR>&#039; Display Previous Link<BR>[% End if %]<BR><BR>[% if PageNo &#060; LastPage then %]<BR>&#039;Display Next Link<BR>[% End If %]<BR><BR>[%<BR>End If<BR>%]

  2. #2
    Join Date
    Dec 1969

    Default RE: RecordSet problems - maximum records on a page

    keep a running tab of how many records have been displayed on the page before you break out of the iteration, then pass that on in the querystring so that you can have an if statement like:<BR><BR>if(request.querystring("counter") &#062; 0)<BR> for(i=0 to counter)<BR> rs.movenext<BR> next<BR>end if<BR>then start displaying records<BR><BR><BR>this way you can always bring yourself back to where you left off displaying on the last page. hope this helps.

Posting Permissions

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