1. Database value to List Box
Open a database, Connect it, retrieve the values with sql and populate the Listbox with them.

<%
set objConn=server.createobject("adodb.connection")
objConn.open "DSN=dbDSN;uid=username;pwd=password"
set rsValues=objConn.execute("select field
from table where )
%>
<Form>
<Select>
<%
do while not rsValues.eof %>
<option> <%=rsValues(0)%> </option>
<%
rsValues.movenext
loop
rsValues.close
set rsValues = nothing
objConn.close
set objConn=nothing
%>
</Select>
</form>

Explanation:

The code connectes the database, takes the values from the table and stores it in a recordset (rsValues). The values are added in to the option form filed one by one using the do…loop and the list has been populated. To use this code Modify the database connection details, and sql.

Back to code snippet home…

    * Macronimous.com does not use information collected in this form for any marketing purposes. Check our privacy policy here.