Display x number of records

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default Display x number of records

    How could I display *only* x# of records even if the select statement
    returns a value >x?
    Dave Karmens Guest

  2. Similar Questions and Discussions

    1. retreve number of records updated
      is there a variable that can be accessed from a query that tells the number of records updated? Thanks KES
    2. How do I report the Total number of Records?
      I am returning a list of records from a database via the XML Connector component, and then into a Dataset (and on into a Datagrid). How do I report...
    3. Total number of records
      When I do a query, how do I get a total number of records found to appear at the bottom of the screen? Thanks
    4. Limited number of instert records
      Hi - Using ASP/Access/Vbscript Is it possible to set a limit of for example 6 insert records of the same type in the DB? Have a product database...
    5. number of records
      hello sir, thank u for help in advance i want to know as to how i can get the number of records obtained in the result of a select query ,the...
  3. #2

    Default Re: Display x number of records

    Select top 10

    or

    SET ROWCOUNT @x
    select ... from tableName ...

    "Dave Karmens" <spam_just1coder@yahoo.ca> wrote in message
    news:OiD%23a7lIEHA.3200@TK2MSFTNGP10.phx.gbl...
    > How could I display *only* x# of records even if the select statement
    > returns a value >x?

    Raymond D'Anjou \(raydan\) Guest

  4. #3

    Default Re: Display x number of records

    Dave Karmens wrote:
    > How could I display *only* x# of records even if the select statement
    > returns a value >x?
    Several options, starting with the best:
    1. Modify the query to only return the number of records you wish to display
    2. When using GetRows to stuff your recordset's data into an array, supply
    the argument to tell the function to only put x records into the array.
    3. Count the records as you write them to the Response object, stopping when
    you've reached the xth record

    For more information, search for recordset paging at aspfaq.com

    HTH,
    Bob Barrows
    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.


    Bob Barrows [MVP] Guest

  5. #4

    Default Re: Display x number of records

    Why not just select x# of them?

    select top 40 ......

    And if for some reason you still want to return them all, then the answer
    depends on how you're currently displaying them. Are you just looping
    through your RS? If so, you could do:

    Dim i
    i = 0
    do while not rs.eof

    ''your code that displays record
    i=i+1
    If i = 40 then exit do
    rs.MoveNext
    Loop

    Ray at work

    "Dave Karmens" <spam_just1coder@yahoo.ca> wrote in message
    news:OiD%23a7lIEHA.3200@TK2MSFTNGP10.phx.gbl...
    > How could I display *only* x# of records even if the select statement
    > returns a value >x?

    Ray at Guest

  6. #5

    Default Re: Display x number of records

    that's it:
    > i=i+1
    > If i = 40 then exit do
    Thanks Ray.

    Ray at <%=sLocation%> [MVP] wrote:
    > Why not just select x# of them?
    >
    > select top 40 ......
    >
    > And if for some reason you still want to return them all, then the answer
    > depends on how you're currently displaying them. Are you just looping
    > through your RS? If so, you could do:
    >
    > Dim i
    > i = 0
    > do while not rs.eof
    >
    > ''your code that displays record
    > i=i+1
    > If i = 40 then exit do
    > rs.MoveNext
    > Loop
    >
    > Ray at work
    >
    > "Dave Karmens" <spam_just1coder@yahoo.ca> wrote in message
    > news:OiD%23a7lIEHA.3200@TK2MSFTNGP10.phx.gbl...
    >
    >>How could I display *only* x# of records even if the select statement
    >>returns a value >x?
    >
    >
    >
    Dave Karmens Guest

  7. #6

    Default Re: Display x number of records

    What's after TOP? by graz - 8/31/2000
    [url]http://www.sqlteam.com/item.asp?ItemID=566[/url]

    Best regards,
    J. Paul Schmidt, Freelance ASP Web Consultant
    [url]http://www.Bullschmidt.com[/url]
    ASP Design Tips, ASP Web Database Demo, Free ASP Bar Chart Tool...


    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Bullschmidt Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139