网络编程 | 站长之家 | 网页制作 | 图形图象 | 操作系统 | 冲浪宝典 | 软件教学 | 网络办公 | 邮件系统 | 网络安全 | 认证考试 | 系统进程
Firefox | IE | Maxthon | 迅雷 | 电驴 | BitComet | FlashGet | QQ | QQ空间 | Vista | 输入法 | Ghost | Word | Excel | wps | Powerpoint
asp | .net | php | jsp | Sql | c# | Ajax | xml | Dreamweaver | FrontPages | Javascript | css | photoshop | fireworks | Flash | Cad | Discuz!
当前位置 > 网站建设学院 > 网络编程 > ASP技巧
Tag:注入,存储过程,分页,安全,优化,xmlhttp,fso,jmail,application,session,防盗链,stream,无组件,组件,md5,乱码,缓存,加密,验证码,算法,cookies,ubb,正则表达式,水印,索引,日志,压缩,base64,url重写,上传,控件,Web.config,JDBC,函数,内存,PDF,迁移,结构,破解,编译,配置,进程,分词,IIS,Apache,Tomcat,phpmyadmin,Gzip,触发器,socket
网络编程:ASP教程,ASP.NET教程,PHP教程,JSP教程,C#教程,数据库,XML教程,Ajax,Java,Perl,Shell,VB教程,Delphi,C/C++教程,软件工程,J2EE/J2ME,移动开发
本月文章推荐
.ASP关于动态数据显示页面得锚点.
.ASP 中健壮的页结构的异常处理.
.XLS与MDB文件格式互换全攻略.
.防范sql注入式攻击js版本.
.如何让图片自动缩放以适合界面大.
.抓取动网论坛Email地址的一段代码 .
.一个BBS的源代码(四).
.在ASP中使用简单Java类.
.ASP中从数据库读取二进制文件数据.
.WebClasses使注册变得容易.
.ASP+ACCESS实现的无限级目录树.
.让ASP也可以连接MYSQL .
.使用ADO批量更新记录(源代码).
.ASP调用带参数存储过程的几种方式.
.用ASP实现在特定的时段或对特定访.
.对于ASP编码问题的深入研究与最终.
.数据分页方法新思路,速度非常快.
.用ASP读取Windows标准INI格式文件.
.在ASP中判断SQL语句是否执行成功.
.asp实现在web中显示电子表格数据.

如何从数据库得到一个列表表单

发表日期:2000-12-22


<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-


上一篇:使用Javascript实现邮箱快速登录的方法!! 人气:11692
下一篇:使用Cookie来跟踪用户 人气:11444
浏览全部的内容 Dreamweaver插件下载 网页广告代码 祝你圣诞节快乐 2009年新年快乐