|
 |
asp_databases thread: how to create no of pages according to the record count.
Message #1 by omkarj@h... on Thu, 22 Feb 2001 10:29:21
|
|
hi,
i have a data base (oracle).
when i open a recordset ... it returns lots of rows .. may be 1 or 10 or 20
so i want to display records on different pages. say 10 one page.
and it will have navigation like(next and prev).
can u please tel howto do this..
Message #2 by "J House" <jesse@s...> on Mon, 26 Feb 2001 03:14:51
|
|
use the recordset proprerties PageSize and PageCount
I never used it with oracle but it should work with any db.
<%
adOpenStatic = 3
intPageSize = 3 'num records to display per page
strMoveType = Request("moveType")
intPageFrom = Request("pageFrom")
' determine what page to display
if strMoveType = "next" then
thisPage = intPageFrom + 1
elseif strMoveType = "prev" then
thisPage = intPageFrom - 1
else
thisPage = 1
end if
set objConn = Server.CreateObject ("ADODB.Connection")
objConn.Open ConnStr
sql = "SELECT * FROM Company"
set objRS = Server.CreateObject ("ADODB.recordset")
objRS.Open sql, objConn, adOpenStatic
'set up pages for record sets
objRS.PageSize = intPageSize
objRS.AbsolutePage = thisPage
intTotalPages = objRS.PageCount
'display records
if Not (objRS.BOF or objRS.EOF) then
i = 0
while (not objRS.EOF) and (i < intPageSize)
Response.Write "<div align=""center"">" & objRS("CompanyName")
& "</div>"
i = i + 1
objRS.MoveNext
wend
end if
'links next and prev.
if thisPage > 1 then
Response.Write "<a href=""test_block.asp?moveType=prev&pageFrom=" &
thisPage & """>Prev</a> "
end if
if thisPage < intTotalPages then
Response.Write "<a href=""test_block.asp?moveType=next&pageFrom=" &
thisPage & """>Next</a> "
end if
%>
hope this helps
'***************************
> hi,
>
>
> i have a data base (oracle).
> when i open a recordset ... it returns lots of rows .. may be 1 or 10 or
20
>
> so i want to display records on different pages. say 10 one page.
> and it will have navigation like(next and prev).
>
> can u please tel howto do this..
>
>
|
|
 |