本站内容搜索:
   您的位置:素材中国>>教程 >>网络编程 >>ASP编程 >>如何从数据库得到一个列表表单 提交错误报告
如何从数据库得到一个列表表单
[ 来源:素材中国 | 作者:| 时间:2006-05-13 09:51:04 | 浏览:人次 ]

 
     <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 WHILE 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 the database must be in the same directory as the script., otherwise, set sPath to the absolute path
  of the database.
  
  The database is assumed to a be an Access 2000 Database with a table Countries with a character field
  Country.
  
  Forms are assumed to point at 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 have problems running this script, your database drivers may be out of date. Go to
  http://www.microsoft.com/data for the current MDAC RTM.
  
  -END-
 
 
       
   您的位置:素材中国>>教程 >>网络编程 >>ASP编程 >>如何从数据库得到一个列表表单
 点此在百度搜索关键字"如何从数据库得到一个列表表单"  点此在GOOGLE搜索关键字"如何从数据库得到一个列表表单"
热门文章:
  ·ASP进度条   ·ASP读取数据库中数据到数组的类
  ·一个简单的ASP+留言板程序   ·如何获取设置图片大小以适应大小在页面上显示
  ·实现有管理功能的ASP留言板   ·用ASP实现图片上传并存入数据库
  ·ASP中DateAdd函数用法   ·ASP程序漏洞解析及黑客入侵防范方法
  ·ASP横向读出数据,一行列出三个记录   ·ASP中几条语句运行速度的测试

  首页  素材图片  高精图库  矢量图库  网页素材  网页模板  壁纸  明星  下载  教程  字体  香车美女  QQ专题  论坛

网站介绍 | 广告业务 | 设计业务 | 免责声明 | 版权声明 | 联系我们|提交错误报告
素材中国版权所有