01.
<%
Option
Explicit %>
02.
<html>
03.
<head>
04.
<title>ThaiCreate.Com ASP & DropDownList From Database</title>
05.
</head>
06.
<body>
07.
<%
08.
09.
Dim
Conn,strSQL,objRec
10.
Set
Conn = Server.Createobject(
"ADODB.Connection"
)
11.
Conn.Open
"DRIVER=Microsoft Access Driver (*.mdb);DBQ="
& Server.MapPath(
"mydatabase.mdb"
),
""
,
""
12.
strSQL =
"SELECT * FROM customer "
13.
Set
objRec = Server.CreateObject(
"ADODB.Recordset"
)
14.
objRec.Open strSQL, Conn, 1,3
15.
%>
16.
<select name=
"select"
>
17.
<option value=
"<!--- Select -->"
>
Select
Items</option>
18.
<%
19.
While
Not
objRec.EOF
20.
%>
21.
<option value=
"<%=objRec.Fields("
CustomerID
").Value%>"
><%=objRec.Fields(
"Name"
).Value%></option>
22.
<%
23.
objRec.MoveNext
24.
Wend
25.
%>
26.
</select>
27.
<%
28.
objRec.Close()
29.
Conn.Close()
30.
Set
objRec =
Nothing
31.
Set
Conn =
Nothing
32.
%>
33.
34.
</body>
35.
</html>