2.2.5. ADO display

发布时间 : 2025-10-25 13:35:19 UTC      

Page Views: 10 views

The most common way to display data from a recordset is to display the data in an HTML table.

Display field name and field value

We have a database named “Northwind”, and we want to display the data in the “Customers” table (remember to .asp save this file for the extension):

<html> <body> <% set conn=Server.CreateObject("ADODB.Connection") conn.Provider="Microsoft.Jet.OLEDB.4.0" conn.Open "c:/webdata/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 & "
"
) next Response.Write("
"
) rs.MoveNext loop rs.close conn.close %> body> html>

Display field names and field values in an HTML table

We can also display the data in the table “Customers” in an HTML table with the following code:

Example

<html> <body> <% set conn=Server.CreateObject("ADODB.Connection") conn.Provider="Microsoft.Jet.OLEDB.4.0" conn.Open "c:/webdata/northwind.mdb" set rs = Server.CreateObject("ADODB.recordset") rs.Open "SELECT Companyname, Contactname FROM Customers", conn %> <table border="1" width="100%"> <%do until rs.EOF%> <tr> <%for each x in rs.Fields%> <td><%Response.Write(x.value)%>td> <%next rs.MoveNext%> tr> <%loop rs.close conn.close %> table> body> html>      

Add a title to the HTML table

Add a title to the HTML table to make it more readable. (keep the file suffix as follows .html ):

Example

<html> <body> <% set conn=Server.CreateObject("ADODB.Connection") conn.Provider="Microsoft.Jet.OLEDB.4.0" conn.Open "c:/webdata/northwind.mdb" set rs = Server.CreateObject("ADODB.recordset") sql="SELECT Companyname, Contactname FROM Customers" rs.Open sql, conn %> <table border="1" width="100%"> <tr> <%for each x in rs.Fields response.write("" & x.name & "") next%> tr> <%do until rs.EOF%> <tr> <%for each x in rs.Fields%> <td><%Response.Write(x.value)%>td> <%next rs.MoveNext%> tr> <%loop rs.close conn.close %> table> body> html>    

image0

《地理信息系统原理、技术与方法》  97

最近几年来,地理信息系统无论是在理论上还是应用上都处在一个飞速发展的阶段。 GIS被应用于多个领域的建模和决策支持,如城市管理、区划、环境整治等等,地理信息成为信息时代重要的组成部分之一; “数字地球”概念的提出,更进一步推动了作为其技术支撑的GIS的发展。 与此同时,一些学者致力于相关的理论研究,如空间感知、空间数据误差、空间关系的形式化等等。 这恰好说明了地理信息系统作为应用技术和学科的两个方面,并且这两个方面构成了相互促进的发展过程。