Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

ASP.NET Forum


You are currently viewing our ASP.NET Forum as a guest. Please register to participate.
Login



Reply
Only List First Ten Entries
Old 11-05-2008, 10:32 AM Only List First Ten Entries
ChipJohns's Avatar
I don't know! Do you?

Posts: 488
Name: Chip Johns
Location: Savannah Georgia
Trades: 0
Hi All,

I am trying to run a script that will only list the last ten entries... The script keeps timing out and will not run. Anybody let me know what I am doing wrong or a better way to accomnplish this?

Here is the code I am using...

Code:
 
<% stri = 1 %>
<% While Not ObjRS1.EOF %>
<% IF stri < 3 THEN  %>
<p class="link">
<a href="article.asp?arID=<% Response.Write ObjRS1("arID") %>"><% Response.Write ObjRS1("arDate") %><br /><% Response.Write ObjRS1("arTitle") %></a></p>
<% stri = stri + 1 %>
<% objRS1.MoveNext %>
<% ELSE %>
<% END IF %>
<%
Wend
objRS1.Close
objConn1.Close
%>
Thanks for any direction
~Chip
ChipJohns is offline
Reply With Quote
View Public Profile Visit ChipJohns's homepage!
 
 
Register now for full access!
Old 11-05-2008, 11:44 AM Re: Only List First Ten Entries
ChipJohns's Avatar
I don't know! Do you?

Posts: 488
Name: Chip Johns
Location: Savannah Georgia
Trades: 0
Figured it out.

Code:
 
<% 
i=1
DO While i <= 10 
%>
 
<p class="link">
<a href="article.asp?arID=<% Response.Write ObjRS1("arID") %>"><% Response.Write ObjRS1("arDate") %><br /><% Response.Write ObjRS1("arTitle") %></a></p>
<% objRS1.MoveNext %>
<% 
i=i+1
LOOP 
%>
<%
objRS1.Close
objConn1.Close
%>
ChipJohns is offline
Reply With Quote
View Public Profile Visit ChipJohns's homepage!
 
Old 11-05-2008, 02:21 PM Re: Only List First Ten Entries
Learning Newbie's Avatar
Defies a Status

Latest Blog Post:
Astounding Republican Paranoia
Posts: 5,662
Name: John Alexander
Trades: 0
If timeouts are your problem, you'll get far better performance (same work achieved in less time) from ASP.NET than from ASP. This has been true for about 8 years now.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Learning Newbie is offline
Reply With Quote
View Public Profile
 
Old 11-07-2008, 07:26 AM Re: Only List First Ten Entries
ChipJohns's Avatar
I don't know! Do you?

Posts: 488
Name: Chip Johns
Location: Savannah Georgia
Trades: 0
I would have to agree with you Newbie; not by personal experience.. I have bought a book on it and am working a little bit with it. Personally I find that asp.net isn't as intuitive as asp. I know I need to learn it but I am finding the learning curve a bit more steep with .net. I probably just need to make myself do it like I did when I first started using asp.

Thanks!

~Chip
ChipJohns is offline
Reply With Quote
View Public Profile Visit ChipJohns's homepage!
 
Old 11-08-2008, 03:04 AM Re: Only List First Ten Entries
itHighway's Avatar
Skilled Talker

Posts: 83
Name: Zeeshan Dar
Location: GUJ
Trades: 0
You can EASILY resolve this issue by changing your sql query:

Exmaple:
SQL = "SELECT TOP 10 * FROM [TABLENAME] ORDER BY arDate DESC"
__________________
Zeeshan Dar
itHighway -
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
itHighway is offline
Reply With Quote
View Public Profile
 
Old 11-08-2008, 04:17 PM Re: Only List First Ten Entries
ChipJohns's Avatar
I don't know! Do you?

Posts: 488
Name: Chip Johns
Location: Savannah Georgia
Trades: 0
No way..!? This will accomplish the same thing?

I'll give it a try,

Thanks

~C
ChipJohns is offline
Reply With Quote
View Public Profile Visit ChipJohns's homepage!
 
Old 11-09-2008, 07:58 AM Re: Only List First Ten Entries
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,515
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
it will for MS SQL server or Oracle.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 11-09-2008, 01:08 PM Re: Only List First Ten Entries
itHighway's Avatar
Skilled Talker

Posts: 83
Name: Zeeshan Dar
Location: GUJ
Trades: 0
Sort your sql query by Article Id or by the date in descending order. This will give last 10 entries.

SQL = "SELECT TOP 10 * FROM [TABLENAME] ORDER BY arDate DESC"

OR

SQL = "SELECT TOP 10 * FROM [TABLENAME] ORDER BY arID DESC"
__________________
Zeeshan Dar
itHighway -
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
itHighway is offline
Reply With Quote
View Public Profile
 
Old 11-11-2008, 03:40 PM Re: Only List First Ten Entries
Learning Newbie's Avatar
Defies a Status

Latest Blog Post:
Astounding Republican Paranoia
Posts: 5,662
Name: John Alexander
Trades: 0
Quote:
Originally Posted by chrishirst View Post
it will for MS SQL server or Oracle.
Actually , it will work in SQL and Access, but not Oracle. In Oracle, you have to use Where XXX and RowCount <= 10.

And for the record, this will perform far better. You're forcing a sort in the database, which adds work, but then you're returning much less client between the database and web server.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Learning Newbie is offline
Reply With Quote
View Public Profile
 
Old 11-12-2008, 10:49 AM Re: Only List First Ten Entries
ChipJohns's Avatar
I don't know! Do you?

Posts: 488
Name: Chip Johns
Location: Savannah Georgia
Trades: 0
I am using access. I will try this and see if I can get it to work.
Thanks everyone for your input...

~C
ChipJohns is offline
Reply With Quote
View Public Profile Visit ChipJohns's homepage!
 
Reply     « Reply to Only List First Ten Entries
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 1.16483 seconds with 12 queries