您的位置:
首页
→
技术开发
→
ASP技巧
→ 如何从数据库得到一个列表表单
如何从数据库得到一个列表表单
时间:2004/11/7 4:10:00
来源:
本站整理
作者:蓝点
我要评论
(0)
ASPHole - Fill List Box Example
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 WHILE NOT oRS.EOF
mSelected = ""
IF mCountry=trim(oRS("Country")) then mSelected=" SELECTED"
%>
><%=oRS("Country")%>
<%
oRS.MoveNext
Loop
%>