Creating an ASP Classic database-driven dropdown menu with [SQL Server] is easy with the following code.
May 30, 2026 - Code has been updated from Movenext to getRows.
Live Lessons Example - Classic ASP Database Driven Select Menu (Dropdown Menu)
Not much coding is involved in this project.
Unlike the original code, this uses [SQL Server] instead of an [Access database].
(Copy and paste are available on the Source Code page)
  1. We will create our database table and load the data for this project.
  2. Create a connection to our database for use in our project.
  3. Show how to close the RecordSet and Database connection.
  4. Create a SELECT statement to populate our select menu.
  5. Demonstrate how to split up files for better code organization.
[ACN.asp]
CFFCS | CarrzSynEdit: | ASP/VBScript
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%
getServer = "sqlcorecs-01"
getInstance = "sql2019"
getID = "testuser"
getPW = "carrz8kiss8*"

Set objConn = CreateObject("ADODB.Connection")
objConn.Open("Provider=SQLOLEDB; Data Source="&getServer&"\"&getInstance&"; Initial Catalog=Virtual-Class-01;User ID="&getID&";Password="&getPW&";")
%>

[Header.asp]
CFFCS | CarrzSynEdit: | ASP/VBScript
<%
' 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 DropDown."
set rsDD = sqlDD.execute
%>

[Main.asp]
CFFCS | CarrzSynEdit: | ASP/VBScript
<!--#include file="ACN.asp"-->
<!--#include file="Header.asp"-->
<!doctype html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ASP Classic SQL Server Database Driven Dropdown Menu</title>
</head>

<body>
<strong>ASP Classic SQL Server Database Driven Dropdown Menu</strong><br />
This demonstration loads all values from a database table into a Select Menu.<br />
<select>
<option value="0">Choose</option>
<%If rsdd.EOF Then
   response.write "Sorry, there are no records in our Database."
else
    arrdd = rsdd.GetRows() ' Loads data into an array

End If
rsdd.close
set rsdd = nothing

If IsArray(arrdd) Then
For dd = 0 To UBound(arrdd, 2)
id = arrdd(0,dd)
ddName = arrdd(1,dd)%>
<option value="<%=id%>"><%=ddName%></option>
<%next
end if
objConn.close
set objConn = Nothing%>
</select>
</body>
</html>

Other Articles Related to this Entry.