Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Mar 2005
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Drop Down list from database

    HI guys,

    I am starting to go a bit mad - please help. I have got a database with about 40 schoolnames that I am trying to display in a drop down but it only shows the first 20 or so records. I have been through it all about 100 times but don't know asp well enough to see where it is not working. I have pasted the code below and would like to thank you in advance:

    <form action="send_email.asp" method=post>
    <select name="schoolname">

    <%
    'Dimension variables
    Dim adoCon 'Holds the Database Connection Object
    Dim rswedweb 'Holds the recordset for the records in the database
    Dim strSQL 'Holds the SQL query for the database
    Dim schoolcont

    'Create an ADO connection object
    Set adoCon = Server.CreateObject("ADODB.Connection")

    'Set an active connection to the Connection object using a DSN-less connection
    adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("Wedweb.mdb")

    'Create an ADO recordset object
    Set rswedweb = Server.CreateObject("ADODB.Recordset")

    'Initialise the strSQL variable with an SQL statement to query the database
    'strSQL = "select schoolcont.schoolname FROM schoolcont ORDER BY schoolname"
    'strSQL = "select schoolcont.schoolname, schoolcont.supported, schoolcont.email FROM schoolcont where schoolcont.supported = 'Y' ORDER BY schoolname"
    strSQL = "select * FROM schoolcont"

    'Open the recordset with the SQL query
    rswedweb.Open strSQL, adoCon

    Do While not rswedweb.EOF
    schoolname = rswedweb("schoolname")
    if Not IsNull(schoolname) then %>


    <%end if%>

    <option value="<%Response.Write rswedweb("schoolname") & ""%></option>
    <%Response.Write rswedweb ("schoolname")%>
    <%rswedweb.MoveNext
    Loop



    'Reset server objects
    rswedweb.Close
    Set rswedweb = Nothing
    Set adoCon = Nothing
    %>
    </select>
    </form>
    </td>

  • #2
    Regular Coder
    Join Date
    Apr 2005
    Location
    Lisbon, CT
    Posts
    339
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Make this change:

    Code:
    <option value="<%=rswedweb("schoolname")%>"><%=rswedweb("schoolname")%></option>
    or
    Code:
    <option value="<%=schoolname%>"><%=schoolname%></option>
    BaldEagle

  • #3
    New Coder
    Join Date
    Mar 2005
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks a lot! This has worked. Much appreciated.



  •  

    Posting Permissions

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