我们可以使用 SQL 来创建查询,这样就可以指定仅查看选定的记录和字段。
我们希望仅仅显示 "Customers" 表的 "Companyname" 字段中以 A 开头的记录:
<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 CustomersWHERE CompanyName LIKE 'A%'"
rs.Open sql, conn%><table border="1" width="100%"> <tr> <%for each x in rs.Fields response.write("<th>" & x.name & "</th>") 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>