Welcome to Dream.In.Code
Become an Expert!

Join 150,071 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,806 people online right now. Registration is fast and FREE... Join Now!




Limiting Database Responses

 
Reply to this topicStart new topic

Limiting Database Responses

meighlow
2 Mar, 2008 - 08:49 PM
Post #1

New D.I.C Head
*

Joined: 27 Jan, 2008
Posts: 15

Hello,

I am working with a database in Oracle. I am using ASP and VBSCRIPT. How can I easily limit the number of search returns to 25 per page with a link to continue to the rest? My site of jobs has hundreds of entries.

Thanks for your help-
User is offlineProfile CardPM
+Quote Post

PsychoCoder
RE: Limiting Database Responses
2 Mar, 2008 - 09:04 PM
Post #2

using DIC.Core;
Group Icon

Joined: 26 Jul, 2007
Posts: 9,483



Thanked: 161 times
Dream Kudos: 9075
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions
Well there are a couple different ways this can be accomplished in ASP, but of course none of them are as easy as it is in ASP.Net. One way to accomplish this is to create a variable that will hold the number of records you want in your page, then as you're looping through your Recordset you make sure you're not at the end of the file and that you havent exceeded your counter variable.

To accomplish this you're going to need to read up on the AbsolutePage Property of the Recordset Object and the PageSize Property of the same object.

When setting the AbsolutePage and PageSize Property do something like this:


vb

Set rs = Server.CreateObject("ADODB.Recordset")
With rs
.CursorType = adOpenStatic
.PageSize = 10
.Open "SELECT JobTitle,URL FROM Jobs ORDER BY TimeStamp DESC", cnn
.AbsolutePage = Cint(pageNum) ' This is the variable you'll create to hold the page number you're on
End With



Once you've set the PageSize Property you can then use that when creating your links, something like this:


vb

'row is a variable you create to keep track of the
'number of records being created in your loop
While Not rs.EOF And row < rs.PageSize
Response.Write "<a href='" & rs("URL") & "'>" & rs("JobTitle") & "</a><br>"
row = row + 1
rs.MoveNext
Wend



NOTE: To use an example like I've shown you're going to need the ADOVBS includes file, which contains the constants you're going to need when creating your paging system.

Hope that helps smile.gif
User is offlineProfile CardPM
+Quote Post

meighlow
RE: Limiting Database Responses
2 Mar, 2008 - 09:09 PM
Post #3

New D.I.C Head
*

Joined: 27 Jan, 2008
Posts: 15

Once again, PsychoCoder, you are a champion!!!
User is offlineProfile CardPM
+Quote Post

PsychoCoder
RE: Limiting Database Responses
2 Mar, 2008 - 09:41 PM
Post #4

using DIC.Core;
Group Icon

Joined: 26 Jul, 2007
Posts: 9,483



Thanked: 161 times
Dream Kudos: 9075
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions
blush.gif Thanks, just glad I could help smile.gif
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/8/09 10:57PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month