Results 1 to 4 of 4

Thread: Reading records in Alphabetical order

  1. #1
    Join Date
    Apr 2006
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Reading records in Alphabetical order

    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

  2. #2
    Join Date
    Apr 2006
    Posts
    429
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    dunno much about ASP but u could try

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

  3. #3
    Join Date
    Apr 2006
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks for your help but that didnt seem to work.
    Hopefully someone else can help.

    Frogger

  4. #4
    Join Date
    Apr 2006
    Posts
    429
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    hhmmm....have u also tried
    Code:
    sqltext = "SELECT * FROM plants ORDER BY filename ASC"
    m sorry i keep wasting ur time....

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •