Page 280 - DCAP408_WEB_PROGRAMMING
P. 280
Web Programming
Notes Certain providers (for example, the Microsoft OLE DB Provider for Internet Publishing) may
populate the Fields collection with a subset of available fields for the Record or Recordset. Other
fields will not be added to the collection until they are first referenced by name or indexed by
your code.
If you attempt to reference a nonexistent field by name, a new Field object will be appended to
the Fields collection with a Status of adFieldPendingInsert. When you call Update, ADO will
create a new field in your data source if allowed by your provider.
When a Recordset object is passed across processes, only the rowset values are marshalled, and
the properties of the Recordset object are ignored. During unmarshalling, the rowset is unpacked
into a newly created Recordset object, which also sets its properties to the default values.
The Recordset object is safe for scripting.
Task Give answers to the following questions:
1. What are the Filter Property Return Values?
2. Explain the The Recordset.Fields Collection.
12.3.1 Sorting of Recordset
We may use SQL to specify how to sort the data in the record set.
Sort the records on a specified fieldname ascending
<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”)
sql=”SELECT Companyname, Contactname FROM Customers ORDER BY CompanyName”
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>
274 LOVELY PROFESSIONAL UNIVERSITY