...

View Full Version : help coding dynamically populated ddown menu



charlieb
08-31-2004, 07:09 AM
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>

A1ien51
08-31-2004, 04:04 PM
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

charlieb
08-31-2004, 08:00 PM
Thanks, I will see if my host can supply an answer

miranda
08-31-2004, 09:09 PM
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.



<%
' 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
%>

oracleguy
08-31-2004, 09:21 PM
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.

charlieb
09-01-2004, 05:39 AM
Thanks everyone, I just realized the problem before your post and fixed it. :D



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum