18
2020
03

ADO 实例:显示记录

ASP源代码:

<html>

<body>


<%

set conn=Server.CreateObject("ADODB.Connection")

conn.Provider="Microsoft.Jet.OLEDB.4.0"

conn.Open(Server.Mappath("/db/northwind.mdb"))

set rs = Server.CreateObject("ADODB.recordset")

rs.Open "Select * from Customers", conn


do until rs.EOF

    for each x in rs.Fields

       Response.Write(x.name)

       Response.Write(" = ")

       Response.Write(x.value & "<br />") 

    next

    Response.Write("<br />")

    rs.MoveNext

loop


rs.close

conn.close

%>


</body>

</html>


运行结果:


CustomerID = Nokia

CompanyName = Nokia Corporation

ContactName = Olli-Pekka Kallasvuo

Address = P.O. Box 226, FIN-00045 Nokia Group, Finland

City = Helsinki

PostalCode = none

Country = Finland


CustomerID = Google

CompanyName = Google, Inc.

ContactName = Larry Page

Address = 1600 Amphitheatre Parkway Mountain View, CA 94043

City = Mountain View

PostalCode = 94043

Country = USA


CustomerID = SONY

CompanyName = Sony Corporation of America

ContactName = Kazuo Hirai

Address = Park Ridge, NJ 07656

City = Park Ridge

PostalCode = 07656

Country = USA


CustomerID = APPLE

CompanyName = Apple Computer, Inc.

ContactName = Steven Jobs

Address = 1 Infinite Loop Cupertino, CA 95014

City = Cupertino

PostalCode = 95014

Country = USA


CustomerID = BAIDU

CompanyName = BAIDU, Inc

ContactName = Li YanHong

Address = Lixiang guoji dasha,No 58, beisihuanxilu

City = Beijing

PostalCode = 100080

Country = China


CustomerID = Canon

CompanyName = Canon USA, Inc.

ContactName = Tsuneji Uchida

Address = One Canon Plaza Lake Success, NY 11042

City = New York

PostalCode = 11042

Country = USA

« 上一篇 下一篇 »

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。