Go Back To List
Basic Classic ASP
Classic ASP Database Driven Select Menu (Dropdown Menu)
Next Article
Classic ASP Database Driven Select Menu to insert data
Coding Article #: 40 - Published On: August 05, 2012 @ 19:07:16 PM - Last Updated on: August 05, 2012
This article has been Favorited 35 times
Join today, and add this to your favorites.
Coding Source - Share on MySpace Coding Source - Share With Facebook Coding Source - Share on Twitter Coding Source - Share on Reddit Coding Source - Share on Digg It Coding Source - Share on Stumble Upon It Coding Source - Share on Delicious
Share With Friends (Updated 6-8-2010)

Supported Files
File Download:
carrzkiss_070932DD.zip
File Size: 12.36 KB
Unzip with
Download winzip today!(OR)
Screenshot of Source Code
Coding Source - Classic ASP Database Driven Select Menu (Dropdown Menu)
In this demonstration, you will be able to code your Select Menu loading data from your database quickly and easily. Using this technique is the best way to get your data loaded quickly.

View Live Example«

Next, we need to get our DATABASE connection.
Below, you can choose to use either JET or Microsoft Access Driver.

<%
Set objConn = CreateObject("ADODB.Connection")
objConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
Server.MapPath ("dd.mdb") & ";"
objConn.Open

' OR
objConn.ConnectionString = "Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=" & _
Server.MapPath ("dd.mdb")
%>


Create our Select Statement. We need to get the records from our database, to display to our page.

<%
' Create the Command to start your SQL and then your RecordSet (rsDD)
Set sqlDD = Server.CreateObject("ADODB.Command")
sqlDD.ActiveConnection=objConn
sqlDD.Prepared = true
sqlDD.commandtext="SELECT ddid, ddname from myTable"
set rsDD = sqlDD.execute
%>


Next, we create our select Field, and polulate it with our database records.
Always remembering to close our the recordset and the database connection at the end.

<select>
<option value="0">Choose</option>
<%if not rsDD.eof then
while not rsDD.eof
id = rsDD("ddid")
ddName = rsDD("ddName")%>
<option value="<%=id%>"><%=ddName%></option>
<%rsDD.movenext
wend
end if
rsDD.close
set rsDD = nothing
objConn.close
set objConn = Nothing%>
</select>
Post to Facebook about: Classic ASP Database Driven Select Menu (Dropdown Menu)