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 6 of 6
  1. #1
    New Coder
    Join Date
    May 2004
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts

    help coding dynamically populated ddown menu

    I am trying to populate a drop down menu with data from sql server database and the page just times out. By the way, I realize there are 2 drop down menus here but right now I'm just trying to get the first one to work. Below is the code, please help:


    ' Connection string
    Dim connStr
    connStr = "dsn=mygreatad;uid=notme;pwd=notreal;network=dbmssocn"

    ' Recordset object
    Dim rs
    Set rs = Server.CreateObject("ADODB.Recordset")

    rs.Open "select Distinct ProjectorName from screenshots ", connStr, adOpenForwardOnly, adLockReadOnly, adCmdText

    %>

    <html>

    <head>
    <meta http-equiv="Content-Language" content="en-us">
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <meta name="GENERATOR" content="Microsoft FrontPage 4.0">
    <meta name="ProgId" content="FrontPage.Editor.Document">
    <title>Projector</title>
    </head>

    <body bgcolor="#FDE19F" text="#000000">


    <form method="POST" action="projectors2.asp">

    <table border="1" width="750" height="304">
    <tr>
    <td width="369" height="18">Projector: <Select Name="ProjectorList" size="1">

    <%While Not rs.EOF%>

    <option value="<%= rs("ProjectorName")%>"> <%= rs("ProjectorName")%></option>

    <%
    rs.MoveNext
    Wend

    rs.Close
    Set rs = Nothing
    Set connStr = Nothing
    %>

    </select>
    </td>
    <td width="365" height="18">Projector: <select size="1" name="D2">
    <option selected>Select Projector</option>
    &nbsp;
    </select>&nbsp; <input type="submit" value="Compare" name="B1"></td>
    </tr>
    <tr>
    <td width="369" height="50">Author:<br>
    Description:</td>
    <td width="365" height="50">Author:<br>
    Description:</td>
    </tr>
    <tr>
    <td width="369" height="37">ScreenShots <font face="Arial" size="1">(click
    to enlarge)</font></td>
    <td width="365" height="37">ScreenShots <font face="Arial" size="1">(click
    to enlarge)</font></td>
    </tr>
    <tr>
    <td width="369" height="259" valign="middle" align="center" bgcolor="#FDE19F"><img border="0" src="../Projector/PICT0005.JPG" width="351" height="265">
    </td>
    <td width="365" height="259" valign="middle" align="center" bgcolor="#FDE19F">&nbsp;<img border="0" src="../Projector/PICT0005.JPG" width="351" height="265"></td>
    </tr>
    </table>
    </form>
    </body>

    </html>

  • #2
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    I do not see anything wrong looking over it quickly and I think it is the same as the link below.

    http://www.takempis.com/asplistbox.asp

    Is the connection to the database timing out?

    Eric
    Last edited by A1ien51; 08-31-2004 at 04:07 PM.
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]

  • #3
    New Coder
    Join Date
    May 2004
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks, I will see if my host can supply an answer

  • #4
    Senior Coder
    Join Date
    Dec 2002
    Location
    Arlington, Texas USA
    Posts
    1,065
    Thanks
    4
    Thanked 8 Times in 8 Posts
    I totally missed that you do not even have a Connection object opened up!!!

    do that and it should work

    You can also try it with the execute method of the connection object thereby eliminating the recordset object.

    Code:
    <%
    ' declare variables
    Dim objConn, connStr, rs, sSQL
    SET objConn = Server.CreateObject("ADODB.Connection")
    connStr = "dsn=mygreatad;uid=notme;pwd=notreal;network=dbmsso cn"
    objConn.Open connStr
    sSQL = "SELECT DISTINCT ProjectorName FROM screenshots"
    Response.write sSQL    ' used for debugging 
    Set rs = objConn.Execute(sSQL)
    
    %>
    
    <html>
    
    <head>
    <meta http-equiv="Content-Language" content="en-us">
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <meta name="GENERATOR" content="Microsoft FrontPage 4.0">
    <meta name="ProgId" content="FrontPage.Editor.Document">
    <title>Projector</title>
    </head>
    
    <body bgcolor="#FDE19F" text="#000000">
    
    
    <form method="POST" action="projectors2.asp">
    
    <table border="1" width="750" height="304">
    <tr>
    <td width="369" height="18">Projector: <Select Name="ProjectorList" size="1">
    
    <%While Not rs.EOF%>
    
    <option value="<%= rs("ProjectorName")%>"> <%= rs("ProjectorName")%></option>
    
    <%
    rs.MoveNext
    Wend
    
    rs.Close
    Set rs = Nothing
    objConn.Close
    Set objConn = Nothing 
    %>
    Last edited by miranda; 08-31-2004 at 09:14 PM.

  • #5
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    charlieb, please in the future when you post code, use the code tags. Its the # button on the toolbar next to the PHP icon on the reply page.
    OracleGuy

  • #6
    New Coder
    Join Date
    May 2004
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks everyone, I just realized the problem before your post and fixed it.


  •  

    Posting Permissions

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