by Anonymous (267 Submissions)
Category: Active Server Pages
Compatability: ASP (Active Server Pages)
Difficulty: Unknown Difficulty
Originally Published: Mon 25th January 1999
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Populate a combo box with information from a database
<SELECT NAME="ListBox" SIZE=1>
<% Set conn = Server.CreateObject("ADODB.Connection") %>
<% conn.Open "DSN=AdvWorks" ' connect to the database %>
<% Set rs = conn.Execute("SELECT City FROM Customers") %>
<% Do While Not rs.EOF ' define the ListBox OPTIONs %>
<OPTION VALUE="<%= rs("City") %>"> <%= rs("City") %>
<% rs.MoveNext %>
<% Loop %>
<% rs.Close %>
<% conn.Close %>