ASP与ASP.NET的比较

开发者在线 Builder.com.cn 更新时间:2007-11-08作者:佚名 来源:yesky

2.敲入以下代码

<%@ Language=VBScript %>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<STYLE>
BODY { font:arial }
H1 { color:navy }
</STYLE>
</HEAD>
<BODY>
<DIV align=center>
<H1>Authors</H1>

<%
'
' Connecting to a database
'
dim cn
set cn = server.CreateObject("ADODB.Connection")
cn.Open "Provider=sqloledb;" _
& "Data Source=(local);" _
& "Initial Catalog=pubs;" _
& "User ID=sa"
' Retrieving Data via the Recordset Object.
dim rs
set rs = server.CreateObject("ADODB.Recordset")
rs.Open "select au_fname, au_lname, phone from authors order by au_lname",cn
%>

  注意:

  下面的代码是由静态HTML和服务器端脚本构成的,用一个循环把数据集(recordset)中的所有数据遍历出来。

<TABLE border='1'>
<TR>
<TH>First Name</TH>
<TH>Last Name</TH>
<TH>Phone</TH>
</TR>
<%
do until rs.EOF
Response.Write "<TR>"
Response.Write "<TD>" & rs("au_fname") & "</TD>"
Response.Write "<TD>" & rs("au_lname") & "</TD>"
Response.Write "<TD>" & rs("phone") & "</TD>"
Response.Write "</TR>"
rs.MoveNext
loop
%>
</TABLE>

<!-- Footer -->
<h5>Current as of <%Response.Write now%></h5>
</DIV>
</BODY>
</HTML>

  3.点击File,再点击Save Authors.asp。

  4.关闭IDE。

用户评论

  • 用户名
  • 评论内容