Home | Advertising Info6 USERS CURRENTLY ONLINE   
PowerASP
   Site Search Contact Us Monday, May 06, 2024  

  Active InfoActive Info  Display List of Info MembersMemberlist  Search The InfoSearch  HelpHelp
  RegisterRegister  LoginLogin
Classic ASP - Database Issues
 PowerASP Code Help Area : Classic ASP - Database Issues
Subject Info: Read from database backwards A d d  -  P o s tAdd P o s t
Author
Message << Prev Info | Next Info >>
Sub_Hum_Ans-666
Newbie
Newbie


Joined: January/26/2006
Location: Australia
Online Status: Offline
Info: 2
Added: January/26/2006 at 7:26am | IP Logged Quote Sub_Hum_Ans-666

I am trying to connect to an access database to display comments sent from users of my site to other users.
i have set varProfileUSER as a variable for the user I want to display the comments for.
The file below is what I have been using, but I want to display newer messages first rather than older ones first, and for this I need to read from the database backwards (or so it would seem)
Is there any way to do this?
This is the script I have so far:
<%
set Conn = server.createobject("ADODB.Connection")
Conn.Open "DRIVER=Microsoft Access Driver (*.mdb);PWD=DBPassword;DBQ="&Server.MapPath("usercomment s.mdb")
set rs=Conn.execute ("Select * From comments")
while not rs.eof
if rs("towho") = varProfileUSER then
response.write("<tr><td width='25%' border='0'>"& rs("fromwho")&"<br>"& rs("time") &" "& rs("date") &"</td><td width='75%' border='0'>"& rs("comment") &"</td></tr>")
end if
rs.movenext
wend
Conn.close
Conn=null
%>

Any help is greatly appreciated
Thanks in advance

Back to Top View Sub_Hum_Ans-666's Profile Search for other info by Sub_Hum_Ans-666
 
firas_TheGeek
Newbie
Newbie
Avatar

Joined: May/27/2006
Location: Oman
Online Status: Offline
Info: 28
Added: May/27/2006 at 8:08am | IP Logged Quote firas_TheGeek

simple, just use the ORDER BY

the code shoudl be like this

set rs=Conn.execute ("Select * From comments ORDER BY date ASC")

if it still gets the same output then change it into this

set rs=Conn.execute ("Select * From comments ORDER BY date DESC")

this way it is sorting the comments by date Accesnding (ASC) or Desccending (DESC)
but if you want to be sorted by other field then simply take out the field date and insert other like time...

 

Hope this helps

 

Best Regards

 



__________________
Firas S Assaad (TheGeek)
firas489@gmail.com
0096892166434
http://firas-thegeek.blogspot.com
Back to Top View firas_TheGeek's Profile Search for other info by firas_TheGeek Visit firas_TheGeek's Homepage
 

If you wish to make a comment to this info you must first login
If you are not already registered you must first register

  A d d  -  P o s tAdd P o s t
Printable version Printable version

Info Jump
You cannot add new info in this area
You cannot add to info in this area
You cannot delete your info in this area
You cannot edit your info in this area
You cannot create polls in this area
You cannot vote in polls in this area

   Active Server Pages Rule The World
Contact Us  
All artwork, design & content contained in this site are Copyright © 1998 - 2024 PowerASP.com and Christopher J. Williams
Banner ads ,other site logos, etc are copyright of their respective companies.
STATS Unless otherwise noted - All Rights Reserved.

Active Server Pages ASP programs help tutorial tutorials routine routines jobs listserve mailinglist bulletin board bulletin boards programming snippet snippets CJWSoft ASPProtect ASPBanner ASPClassifieds www.aspprotect.com, www.cjwsoft.com,www.aspclassifieds.com,www.aspphotogallery.com