A better way of doing this, in order to minimize the server load and
network traffic, specially since this is such a huge table, is to do the
paging on the database side. Otherwise, you are retrieving the entire table
for only x (in this case, 7) records, which is highly inefficient the more
records you have.
Basically, write a stored procedure, standalone or in a package, and pass
in the page number you want, and the number of records per page, and return
only that. This also simplifies the operations on the ASP page. The proc
would look something like this (sorry, no Oracle connection at home, so
this is from memory):
-----
(This should go in the package Spec)
TYPE TableRowType IS TableName%ROWTYPE;
PROCEDURE GetDataRecords(
PageNumber IN NUMBER,
RecordsPerPage IN NUMBER,
oDataset OUT );
(This goes in the package body)
PROCEDURE GetDataRecords(
PageNumber IN NUMBER,
RecordsPerPage IN NUMBER,
oDataset OUT oDataset)
AS
nStartRecord NUMBER;
nEndRecord NUMBER;
BEGIN
nStartRecord := 1 +((PageNumber - 1) * RecordsPerPage);
nEndRecord := PageNumber * RecordsPerPage;
OPEN oDataset FOR
SELECT *
FROM TableName
WHERE ROWNUM BETWEEN nStartRecord AND nEndRecord;
END GetDataRecords;
------------
That will allow you to change the page size should the requirements change
at some point (not that THAT would EVER happen!) or give you the chance to
make it more dynamic, such as passing in a table or view name to allow
reuse the code.
HTH,
HD
At 05:01 AM 2/9/2005, you wrote:
>Hi
>
>for this type ASP provide Paging . in this you have to define no of max.
>record you want to show at a time , this is a property of recordset ,
>yr case it will be 7 ....
>
>i am giving the simple code read this .. or you can get lot of example in net
>
><[EMAIL PROTECTED]>
><%
>' Define variables
>dim recordsonpage, requestrecords, offset, allrecords, hiddenrecords,
>showrecords, lastrecord, recordcounter, pagelist, pagelistcounter
>' DB connection
>dim Conn
>Set Conn = Server.CreateObject("ADODB.Connection")
> sConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
> "Data Source=" & Server.MapPath("cddatabase.mdb") & ";" & _
> "Persist Security Info=True"
>Conn.Open(sConnection)
>' records per page
>recordsonpage = 10
>' count all records
>allrecords = 0
>set rs = conn.Execute("SELECT * FROM cds")
>do until rs.EOF
> allrecords = allrecords + 1
> rs.movenext
>loop
>' if offset is zero then the first page will be loaded
>offset = request.querystring("offset")
>if offset = 0 OR offset = "" then
> requestrecords = 0
>else
> requestrecords = requestrecords + offset
>end if
>' opens database
>set rs = conn.Execute("SELECT * FROM cds ORDER BY cdid")
>' reads first records (offset) without showing them (can't find another
>solution!)
>hiddenrecords = requestrecords
>do until hiddenrecords = 0 OR rs.EOF
> hiddenrecords = hiddenrecords - 1
> rs.movenext
> if rs.EOF then
> lastrecord = 1
> end if
>loop
>%>
><% ' prints records in the table showrecords = recordsonpage recordcounter
>= requestrecords do until showrecords = 0 OR rs.EOF recordcounter =
>recordcounter + 1 %>
><% = recordcounter %> <% = rs("cdid") %> <% = rs("title") %>
><% showrecords = showrecords - 1 rs.movenext if rs.EOF then lastrecord = 1
>end if loop %>
>
><% if requestrecords <> 0 then %><paging.htm>Prev Page<% else %>Prev
>Page<% end if %> <% if lastrecord <> 1 then %> <paging.htm>Next Page<%
>else %>Next Page<% end if %>
>pagelist: <% pagelist = 0 pagelistcounter = 0 do until pagelist >
>allrecords pagelistcounter = pagelistcounter + 1 %> <paging.htm><% =
>pagelistcounter %> <% pagelist = pagelist + recordsonpage loop %>
><% ' Closes connection rs.close Conn.close %>
>Ghassan <[EMAIL PROTECTED]> wrote:
>
>There's a friend who is working on a web that retrieves information
>from an Oracle DB and display as a table, the thing is that the
>information is huge, and the table seems endless, what's the best way
>in ASP to divide this table each 7 columns for example with a
>dynamically displayed next button in the bottom, create a new page,
>put the next 7 columns in it, and so on.
>
>By the way I'm kind of newbie, so kindly explain what for what in the
>code.
>
>Thanx in advanced
>
>Ghassan Yonis
>
>
>
>
>
>ASP Resources www.asp-dev.com
>
>============================================================
>Learn over lunch. Get the developerWorks newsletter and
>enjoy tools, code, and tutorials, along with your sandwich.
>XML, Linux, Web services, Java -- and peanut butter!
>http://www.topica.com/partner/AP-1RMZ49/partners/ibm/aff_landing.html
>============================================================
>
>
>
>
>
>Yahoo! Groups SponsorADVERTISEMENT
>document.write('');
>
>---------------------------------
>Yahoo! Groups Links
>
> To visit your group on the web, go to:
>http://groups.yahoo.com/group/asp/
>
> To unsubscribe from this group, send an email to:
>[EMAIL PROTECTED]
>
> Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
>
>
>
>---------------------------------
>Do you Yahoo!?
> Yahoo! Search presents - Jib Jab's 'Second Term'
>
>[Non-text portions of this message have been removed]
>
>
>
>ASP Resources www.asp-dev.com
>
>============================================================
>Learn over lunch. Get the developerWorks newsletter and
>enjoy tools, code, and tutorials, along with your sandwich.
>XML, Linux, Web services, Java -- and peanut butter!
>http://www.topica.com/partner/AP-1RMZ49/partners/ibm/aff_landing.html
>============================================================
>
>
>
>Yahoo! Groups Links
>
>
>
>
ASP Resources www.asp-dev.com
============================================================
Learn over lunch. Get the developerWorks newsletter and
enjoy tools, code, and tutorials, along with your sandwich.
XML, Linux, Web services, Java -- and peanut butter!
http://www.topica.com/partner/AP-1RMZ49/partners/ibm/aff_landing.html
============================================================
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/asp/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/