<HEAD>
<title>asphole-fill List Box example</title>
</HEAD>
<BODY>
<form method=post>
Country: <select name= "Country" >
<%
' Construct path to database
spath = Request.ServerVariables ("path_translated")
spath = Left (Spath,instrrev (spath, "\")) & "Countries.mdb"
'
' Open Connection & Recordset
Set osample = Server.CreateObject ("ADODB. Connection ")
Osample.open _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Persist security Info=true;" & _
"Data source=" & spath, "Admin", ""
'
' Check for default ...
Mcountry = Trim (Request ("Country"))
'
' Create the ' List
Set Ors=osample.execute _
("Select Id,country" & _
"From COUNTRIES" & _
"ORDER by ID")
Do as not ors.eof
mselected = ""
IF Mcountry=trim (ORS ("Country")) then mselected= "SELECTED"
%>
<option<%=mselected%>><%=ors ("Country")%></option>
<%
Ors.movenext
Loop
%>
</SELECT><BR>
<input type=submit>
</FORM>
</BODY>
</HTML>
Key Points of the sample:
Spath is used to construct the ' path to the ' database based on the home directory of the script. This means
That database must is in the same directory as the script., otherwise, set spath to the absolute path
The database.
The database is assumed to a being an Access database with a table Countries with a character field
Country.
Forms are assumed to point in the same script which created it unless action is specified.
The IF mcountry= ... statement is used to insert the word SELECTED into the OPTION containing the previous
Country value, should one have been passed in by a submit.
If you are have problems running this script, your database drivers may is out of date. Go to
Http://www.microsoft.com/data for the current MDAC RTM.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service