...

View Full Version : ASP drop down list



FedEx
08-31-2005, 07:03 AM
I created a dropdown list populated with data from Access database using ASP. The following is the code:

<select name="ID">
<option></option>
<%
Do While Not objRS.EOF
%>
<option value="<%= objRS.Fields("ID") %>"><%= objRS.Fields("ADDRESS") %></option>

<%
objRS.MoveNext
Loop
%>
</select>

It successfully displays the data from the database in sequence order, sort by ID. As a result, the dropdown displays Address1 (ID=1) at the very top, follow by Address2 (ID=2) etc. However, I want to display the list in reverse order, which starts with the very last line in the databse then descending down to line 1. My SQL queries is just a very simple 'Select * from table' query.
Can anyone please tell me what do I need to modify in the above code to reverse the display order? Do I also need to add the 'order by xx' query to the SQL query? Many thanks.

NancyJ
08-31-2005, 10:37 AM
Just add "order by id desc" to your query

Bullschmidt
09-02-2005, 05:14 AM
Just add "order by id desc" to your query


Way to go Nancy - a good answer in 10 words or less (seems like that's hard to do around here)! :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum