Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Paging through recordset

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,2461
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Paging through recordset
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Paging through recordset - 3/24/2005 2:40:27 AM   
  zahid_a

 

Posts: 14
Score: 0
Joined: 2/16/2005
From: Canada
Status: offline
Posted - 03/23/2005 : 11:49:12 AM
--------------------------------------------------------------------------------

hi...
i have this script and its giving me problems when i try to page through the database. i cant figure out; as to why its not passing the parameter onto the next page when i click on NEXT...
when i click on NEXT it displays the complete database; as if not reading the parameter provided (if its being provided)...but it gives correct results on the first page....any help will be much appreciated....

thanks a lot.. and here is my code...

<% OPTION EXPLICIT %>
<!-- #INCLUDE FILE ='connection.asp' -->
<!-- METADATA TYPE = "typelib"
FILE = "C:\Program Files\Common Files\System\ado\msado15.dll" -->


<html>
<head>
<title> AUTHOR SEARCH </title>
</head>
<body>

<%

Dim objRS, AUTHOR, nPage, nPageCount, strSQL


AUTHOR = Request.Form("AUTHOR")
AUTHOR = Replace(AUTHOR, "'", "''")

strSQL = "SELECT CallNumber, Author, Title, Series, Edition, Publisher, Date, ISBN, Description, Subject, Notes FROM nova WHERE Author LIKE '%" & AUTHOR & "%' ORDER BY Author"

Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.PageSize = 10
objRS.CacheSize = 10
objRS.CursorLocation = adUseClient
objRS.Open strSQL, Conn, adOpenStatic


If objRS.EOF Then
Response.Write "No Results Found"
Else

nPageCount = objRS.PageCount
Response.Write "There are: " & "<b>" & nPageCount & "</b>" & " pages." & "<br>"
Response.Write "<b>" & objRS.RecordCount & "</b>" & " records found."
Response.Write "<br>" & "<hr>"

nPage = CLng(Request.QueryString("Page"))

If nPage < 1 OR nPage > nPageCount Then
nPage = 1
Else
End If

objRS.AbsolutePage = nPage

Do While Not (objRS.EOF OR objRS.AbsolutePage <>nPage)


Response.Write "<B>" & "Call Number: " & "</b>" & objRS("CallNumber") & "<BR>"

Response.Write "<B>" & "Author: " & "</b>" & objRS("Author") & "<BR>"

Response.Write "<B>" & "Title: " & "</b>" & objRS("Title") & "<BR>"

Response.Write "<B>" & "Series: " & "</b>" & objRS("Series") & "<BR>"

Response.Write "<B>" & "Edition: " & "</b>" & objRS("Edition") & "<BR>"

Response.Write "<B>" & "Publisher: " & "</b>" & objRS("Publisher") & "<BR>"

Response.Write "<B>" & "Date: " & "</b>" & objRS("Date") & "<BR>"

Response.Write "<B>" & "ISBN: " & "</b>" & objRS("ISBN") & "<BR>"

Response.Write "<B>" & "Description: " & "</b>" & objRS("Description") & "<BR>"

Response.Write "<B>" & "Subject: " & "</b>" & objRS("Subject") & "<BR>"

Response.Write "<B>" & "Notes: " & "</b>" & objRS("Notes") & "<BR>"

Response.Write "<hr>"
objRS.MoveNext
Loop

Response.Write "<div align=""center"">" & vbcrlf


' First page
If objRS.PageCount = 1 Then
Response.Write "<span style=""color:silver;"">First Page</span>"
Response.Write " | "
Else
Response.Write "<A HREF=""authorcode.asp?AUTHOR=" & AUTHOR & "&Page=1"">First Page</A> "
Response.Write " | "
End If


' Previous page:
If objRS.PageCount = 1 OR nPage = 1 Then
Response.Write "<span style=""color:silver;"">Previous Page</span>"
Response.Write " | "
Else
Response.Write "<A HREF=""authorcode.asp?AUTHOR=" & AUTHOR & "&Page=" & nPage - 1 & """>Previous Page</A> "
Response.Write " | "
End If


' Next page
If objRS.PageCount = 1 OR nPage = nPageCount Then
Response.Write "<span style=""color:silver;"">Next Page</span>"
Response.Write " | "
Else
Response.Write "<A HREF=""authorcode.asp?AUTHOR=" & AUTHOR & "&Page=" & nPage + 1 &""">Next Page</A> "
Response.Write " | "
End If


' Last page
If objRS.PageCount = 1 Then
Response.Write "<span style=""color:silver;"">Last Page</span>"
Response.Write " | "
Else
Response.Write "<A HREF=""authorcode.asp?AUTHOR=" & AUTHOR & "&Page=" & nPageCount & """>Last Page</A> "
Response.Write " | "
Response.Write "</div>"
End If

End If



objRS.Close
Set objRS = Nothing


%>

</body>
</html>

_____________________________

zahid
 
 
Post #: 1
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Paging through recordset Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts