paging through a database

Results 1 to 2 of 2

Thread: paging through a database

  1. #1
    Join Date
    Dec 1969

    Default paging through a database

    I know that their is an answer to this question in ASPfaqs but I cannot seem to figure it out. I am trying to print out the first 5 records from a database and have a link at the bottom that will be to the next five and so on. I just don&#039t want all the records on one page. The problem is that I can display the first five but I do not know how to get back to the record I left off on. This is the code I am using so far any help would be appreciated.<BR><BR>&#060;% <BR><BR> Set DBConn = Server.CreateObject("ADODB.Connection")<BR> DBConn.Open "mainerec"<BR><BR> SQL = "SELECT * FROM Categories" <BR> Set QTable = DBConn.Execute(SQL)<BR> <BR> Set objRS = DBConn.Execute(SQL)<BR><BR> &#039We need to create a counting variable to keep track of<BR> &#039the total number of records we&#039ve processed<BR> Dim iRecordCount<BR> if Request.QueryString("rc") = "" then<BR> iRecordCount = 0<BR> else<BR> iRecordCount = Request.QueryString("rc")<BR> end if<BR> theCount = iRecordCount + 5<BR> Do While Not objRS.EOF<BR><BR> Do While Not QTable.EOF and iRecordCount &#060;&#062; theCount<BR> &#039Increment the number of records processed by 1<BR> iRecordCount = iRecordCount + 1<BR> <BR> Response.Write iRecordCount & "<BR>"<BR> <BR> Response.Write "&#060;b&#062;" & QTable("CatName") & "&#060;/b&#062;&#060;/br&#062;"<BR> <BR> <BR> QTable.MoveNext<BR> Loop<BR> <BR> &#039Move on to the next listing<BR> objRS.MoveNext<BR> Loop<BR> <BR>%&#062;<BR><BR>&#060;a href="next.asp?rc=&#060;%= iRecordCount %&#062;"&#062;Next&#060;/a&#062;

  2. #2
    Join Date
    Dec 1969

    Default RE: paging through a database

    use a SQL string such as <BR>SQL="select * from nameofdbase where recordid &#062; " & bottomnumber & "recordid&#060;" & topnumber &";"

Posting Permissions

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