<html>
<title>www.ttasp.net(Basic Table Display (Where Clause Hard-Coded))</title>
<body bgcolor="#FFFFFF">
<%
'正在读取的Accessdb名称
accessdb="fidrych"
'关联到DSN-less连接的数据库
cn="DRIVER={Microsoft Access Driver (*.mdb)};"
cn=cn & "DBQ=" & server.mappath(accessdb)
'创建一个记录设置对象服务器
Set rs = Server.CreateObject("ADODB.Recordset")
'选择the table the_bird where the year=1976的所有数据
sql = "select * from the_bird where year=1976"
'执行sql
rs.Open sql, cn
%>
<table BORDER="1" align="center" width="640">
<caption>Mark <i>The Bird</i> Fidrych Rookie Stats</caption>
<tr>
<td>Year</td>
<td>Team</td>
<td>W</td>
<td>L</td>
<td>G</td>
<td>GS</td>
<td>CG</td>
<td>IP</td>
<td>H</td>
<td>BB</td>
<td>SO</td>
<td>ShO</td>
<td>ERA</td>
</tr>
<%
'移动到第一个记录
rs.movefirst
'开始以最后记录结束的循环
do while not rs.eof
%>
<tr>
<td>
<%= rs("year") %>
</td>
<td>
<%= rs("team") %>
</td>
<td>
<%= rs("w") %>
</td>
<td>
<%= rs("l") %>
</td>
<td>
<%= rs("g") %>
</td>
<td>
<%= rs("gs") %>
</td>
<td>
<%= rs("cg") %>
</td>
<td>
<%= rs("ip") %>
</td>
<td>
<%= rs("h") %>
</td>
<td>
<%= rs("bb") %>
</td>
<td>
<%= rs("so") %>
</td>
<td>
<%= rs("sho") %>
</td>
<td>
<%= rs("era") %>
</td>
</tr>
<%
'移动到下个记录
rs.movenext
'循环回到do语句
loop %>
</table>
</body>
</html>
<%
'关闭和设置记录设置为无
rs.close
set rs=nothing
%>
显示特定的数据库的子设置数据是对于完成.asp很容易的。下面的例子利用了我们的Mark "The Bird" Fidrych的Access 数据库,显示他的所有的包括没有显示完整数据库的数据库的1976年的季节性信息。
热门信息
阅读 (167)
1 独特的随机字母阅读 (143)
2 检查和设置IIS服务器正确的权限阅读 (139)
3 存在的文件阅读 (134)
4 随机图像阅读 (131)
5 ASP读取、解析JSON数据