Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how can I read records in reverse order

Status
Not open for further replies.

gargs

Technical User
Apr 3, 2001
14
NZ
I have written a small message board script in asp that uses an access database to store usernames and messages, there is also a date feild that is set to Now() to display the the date and time the message was posted (much like this site I suppose).

How do I list the records in descending date order?

It may be glaringly obvious, but please help...

Thanks in advance
 
When you select the data from the database, just sort the data by date before you write it out.

e.g

set myRS = myConn.Execute "SELECT * FROM myTable SORT BY myDate DESC"

do while not myRS.EOF
Response.Write myRS("myDate") & myRS("user") & myRS("message")
myRS.MoveNext
loop

Something along those lines should work. Hope that helps.
Mise Le Meas,

Mighty :)
 
Thanks for the tip but now I'm getting an error.

This is the code I'm using

SQLstmt = "SELECT * FROM cd SORT BY date DESC"
Set rs = conn.Execute(SQLstmt)

This is the error I'm now getting

Microsoft JET Database Engine (0x80040E14)
Syntax error in FROM clause.
/forum/default.asp, line 131

Any Ideas??

 
Sorry, my mistake. It should be:

SQLstmt = "SELECT * FROM cd ORDER BY date DESC"
Mise Le Meas,

Mighty :)
 
Nice...

Thanks man, all working now.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top