PDA

View Full Version : Reading records in Alphabetical order



Frogger
07-09-2006, 01:04 AM
Hi,

Can someone please help me with this. I cant seem to work out why its not working.


<select id="list2" onchange="document.getElementById('blank2').src=this.options[this.selectedIndex].value">
<%
Response.Buffer = true


set cnn = Server.CreateObject("ADODB.Connection")
set rst = Server.CreateObject("ADODB.RecordSet")
cnn.Open "driver={Microsoft Access Driver (*.mdb)};;DBQ=c:/Mandy/plants.mdb;"
sqltext = "SELECT * FROM plants"

Set RS = cnn.Execute(sqltext)
WHILE NOT RS.EOF

%>
<option value="<%=RS("filename")%>"><%=RS("plantname")%></option>
<%
RS.MoveNext
WEND
RS.Close
cnn.Close
%>
</select>

For some reason my ASP script reads the access database records in the order that the records were put in. The access database is saved in alphabetical order. How do I get my combo boxes to display the records in alphabetical order as to the access database ?

Regards
Frogger

jr_yeo
07-09-2006, 01:22 AM
dunno much about ASP but u could try



sqltext = "SELECT * FROM plants ORDER BY yourtablename ASC"
// ASC means ascending order and DESC means descending order

Frogger
07-09-2006, 09:40 AM
Thanks for your help but that didnt seem to work.
Hopefully someone else can help.

Frogger

jr_yeo
07-09-2006, 09:48 AM
hhmmm....have u also tried

sqltext = "SELECT * FROM plants ORDER BY filename ASC"

m sorry :D i keep wasting ur time.... :o