I have the following code to populate a dropdown box. I'm in need of anoter dropdown populated from the database on the same page.
<%
Dim DataConn
Dim CmdPopulateStates
Dim SQL
Set DataConn = Server.CreateObject("ADODB.Connection")
Set CmdPopulateStates = Server.CreateObject("ADODB.Recordset")
%>
Take away the comment on Sytem DSN version below if you want to use a system DSN instead and add a comment to the DSN-LESS connection version below it
<%
DataConn.Open "DBQ=" & Server.Mappath("_database/zipcodes.mdb") & ";Driver={Microsoft Access Driver (*.mdb)};"
SQL = "SELECT DISTINCT STATE_NAME FROM STATES"
CmdPopulateStates.Open SQL, DataConn
%>
<form method="POST" action="somepage.asp">
<Select Name="STATE_NAME" size="1">
<%While Not CmdPopulateStates.EOF%>
<option value="<%= CmdPopulateStates("STATE_NAME") %>"><%= CmdPopulateStates("STATE_NAME") %></option>
<%
CmdPopulateStates.MoveNext
Wend
CmdPopulateStates.Close
Set CmdPopulateStates = Nothing
DataConn.Close
Set DataConn = Nothing
%>
</Select>
<input type="submit" value="Submit">
</form>
Is it as simple as creating a second recordset, sql, and repeating the "CmdPopulateStates.Open SQL, DataConn" command calling the relevant sql name?


Reply With Quote
Bookmarks