Beginner Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOtherBeginner Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old August 15th, 2000, 09:21 PM
jenice jenice is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2000
Posts: 6 jenice User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
hey
i hope to get help in retriving data from sql using paging in asp code.

hope someone out there can help me out.

thanks

jenice

Reply With Quote
  #2  
Old July 25th, 2001, 05:31 AM
SavageKid SavageKid is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2001
Location: Chennai,India
Posts: 25 SavageKid User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to SavageKid Send a message via Yahoo to SavageKid
Thumbs up Savage here

Hi,
Try this code

<!-- #include file="adovbs.inc" -->
<%

Dim iPageSize 'How big our pages are
Dim iPageCount 'The number of pages we get back
Dim iPageCurrent 'The page we want to show
Dim iRecordsShown 'Loop controller for displaying just iPageSize records


iPageSize = 5

If Request.QueryString("p") = "" Then
iPageCurrent = 1
Else
iPageCurrent = CInt(Request.QueryString("p"))
End If

Set oConn = server.createObject("ADODB.Connection")
sDSN = "DRIVER={SQL Server};SERVER=yourservername;UID=uid;PWD=pwd"
oConn.open sDSN
Set oRS=server.createobject("adodb.recordset")
oRS.PageSize = iPageSize
oRS.CacheSize = iPageSize
oRS.Open "select * from temptable",oConn,adOpenStatic, adLockReadOnly, adCmdText
%>
<html>
<head>
</head>

<body>
<%
iPageCount = oRS.PageCount
If iPageCurrent > iPageCount Then iPageCurrent = iPageCount
If iPageCurrent < 1 Then iPageCurrent = 1
If not iPageCount = 0 Then
oRS.AbsolutePage = iPageCurrent
iRecordsShown = 0
Do While iRecordsShown < iPageSize And Not oRS.EOF
response.write oRS.fields(0)&"<br>" ' You can format the table here I am just displaying one field
iRecordsShown = iRecordsShown + 1
oRS.movenext
Loop
If iPageCurrent > 1 Then
%>
<a href="trial.asp?p=<%= iPageCurrent - 1 %>"><< Prev</a>
<%
End If
For I = 1 To iPageCount
If I = iPageCurrent Then
%>
<%= I %>
<%Else%>
<a href="trial.asp?p=<%= I %>"><%= I %></a>
<%
End If
Next 'I
If iPageCurrent < iPageCount Then
%>
<a href="m_list.asp?p=<%= iPageCurrent + 1 %>">Next >></a>
<%End If%>
</body>
</html>

You require the adovbs.inc file however for this code.

C'ya

Savage

Reply With Quote
Reply

Viewing: Dev Shed ForumsOtherBeginner Programming > paging in asp


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway