473,399 Members | 3,832 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

How to limit the amount of entries listed?

23
I have the following code setup on my homepage. I was wondering if it would be possible to limit the output to say: 10, 15, 25 entries. Right now it seems limitless.

Expand|Select|Wrap|Line Numbers
  1. <%
  2.         rsG.open "select OrganizationId,OrganizationName,update_date from tblOrganizations where isFeatured=1 order by update_date",conn
  3.         rsCnt2.Open "select count(*) as cnt from tblOrganizations where isFeatured=1",conn
  4.         if not rsCnt2.eof then
  5.         finalCount=finalcount+rsCnt2("cnt")
  6.         end if
  7.         rsCnt2.close
  8.  
  9.  
  10.         numberRows=finalCount/4
  11.         incr=finalcount mod 4
  12.         numberRows=round(numberRows)+incr
  13.  
  14.         if rsG.eof and rsG.bof then
  15.         else                    
  16.                     iCol=0
  17.                     while not rsG.EOF 
  18.                     if iCol=numberRows and finalCount>4 then
  19.                     Response.Write "</table></td><td valign=top><table border=0>"
  20.                     iCol=0
  21.                     end if 
  22.                     Response.Write "<tr><td valign=top align=left><a href=groupProfile.asp?grpid=" & rsG("OrganizationID") & ">" & rsG("OrganizationName") & "</a></td></tr>"
  23.                     iCol=iCol+1
  24.                     rsG.MoveNext
  25.                     wend
  26.  
  27.         end if
  28.  
  29.         %>
Thanks in advance
Mar 1 '11 #1

✓ answered by jhardman

Depending on which type of db you have, one of these might work:
Expand|Select|Wrap|Line Numbers
  1. rsG.open "select top 25 OrganizationId,OrganizationName,..."
or
Expand|Select|Wrap|Line Numbers
  1. rsG.open "set rowcount 25; select OrganizationId,OrganizationName,...
let me know if this helps.

Jared

6 1787
jhardman
3,406 Expert 2GB
Depending on which type of db you have, one of these might work:
Expand|Select|Wrap|Line Numbers
  1. rsG.open "select top 25 OrganizationId,OrganizationName,..."
or
Expand|Select|Wrap|Line Numbers
  1. rsG.open "set rowcount 25; select OrganizationId,OrganizationName,...
let me know if this helps.

Jared
Mar 1 '11 #2
user65
23
Greatly appreciate the reply, Thank you Jared. Unfortunately neither of those worked, here is the error I got when implementing them:

I am using microsoft sql 2005 if that helps

Expand|Select|Wrap|Line Numbers
  1. Microsoft VBScript compilation error '800a03ea'
  2.  
  3. Syntax error
  4.  
  5. /default-new.asp, line 278
  6.  
  7. rsG.open*"select*top 25 OrganizationId,OrganizationName,update_date from tblOrganizations where isFeatured=1 order by update_date",conn
  8. --------^
Expand|Select|Wrap|Line Numbers
  1. Microsoft VBScript compilation error '800a03ea'
  2.  
  3. Syntax error
  4.  
  5. /default-new.asp, line 278
  6.  
  7. rsG.open*"set rowcount 25; select*OrganizationId,OrganizationName,update_date from tblOrganizations where isFeatured=1 order by update_date",conn
  8. --------^
Mar 1 '11 #3
jhardman
3,406 Expert 2GB
Tell me what db you are using and we can adapt this.

Otherwise we can set the numberRows variable to any arbitrary number you want.
Expand|Select|Wrap|Line Numbers
  1. numberRows=25 
Jared
Mar 1 '11 #4
user65
23
I am using microsoft sql server 2005 on windows 2003 r2.
Mar 3 '11 #5
jhardman
3,406 Expert 2GB
Oh duh, stupid mistake! I don't know where those asterisks came from, I didn't notice them when I posted that reply. When I saw it in your reply I thought it was something the error message had inserted to indicate the location of the error. I'll edit my earlier post to correct that.

Both methods should work for sql server.

Jared
Mar 3 '11 #6
user65
23
Worked great!! The asterisks were what was causing my foul up. Many thanks Jared!!
Mar 3 '11 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: James Butler | last post by:
Running a CLI script that fopen's a file, parses the lines into an array, checks the array entries against a few regular expression qualifiers (i.e. !eregi("bot",$entry)) and dump the good entries...
5
by: Nancy | last post by:
I have two tables: TblCourse CourseID CourseName TblClass ClassID CourseID ClassDate
6
by: Hannu | last post by:
Hi. In the ldb file you can see the users of the mdb-file. If you open the mdb-file your machine and username will be written in the lbd- file. Allthough you close the mdb-file your name won't...
9
by: Terry E Dow | last post by:
Howdy, I am having trouble with the objectCategory=group member.Count attribute. I get one of three counts, a number between 1-999, no member (does not contain member property), or 0. Using...
6
by: Daniel Walzenbach | last post by:
Hi, I have a web application which sometimes throws an “out of memory” exception. To get an idea what happens I traced some values using performance monitor and got the following values (for...
1
by: renahkw | last post by:
How can I easily limit the amount of rows displayed in a table, and then navigate from page to page? Each row consists of 3 cells: the first, containing a varying number of images followed by some...
1
by: new2asp | last post by:
I am new to ASP, and I am trying to figure out how to create a registration form that can limit that amount of people who are signing up for an event. The form has to take in consideration the...
2
by: scolivas | last post by:
Hi to all...I am playing around with a voting database and was wondering if anyone could give me some ideas. I want to make it so that no one person can vote more than once. No matter how many...
1
by: DAHMB | last post by:
I have a column in a report that I want to return a sum of certain criteria from a query between two dates. I set the dates in a form that I launch the report from. My query contains a field called...
10
by: orsula | last post by:
Hi Guys, I have a class A composed of several string and int members. I would like to manage a huge amount (several thousands) of A objects in a dictionary where each object has its unique key....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.