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
%>
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.
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.
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
__________________
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?
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
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.