Page 285 - DCAP408_WEB_PROGRAMMING
P. 285
Unit 12: Recordset Object
Pro ADO.NET 2.0 Notes
from Dreamtech Press (www.wileydreamtech.com) . “ActiveX Data Objects (ADO) was
the premier data access technology under the Microsoft umbrella before ADO.NET was
introduced as an integral part of the .NET Framework,” chronicles Malik.
“What sets ADO.NET apart from previous data access technologies is that it allows you to
interact with your database in a completely disconnected data cache to work with data
offline.”
Disconnected data access is crucial for today’s high-demand applications, notes the author.
The book has chapters on connecting to a data source, retrieving data in a connected
fashion, DataSets, sorting and searching, updating data, and so on. Of value is the chapter
on ‘best practices’ where Malik discusses the right tools. For instance, he reminds that data
reader consumes less memory than a DataSet.
“A data reader is an object that allows you to access information on only a single row of
data at a given time.
What this means is that, regardless of the size of a result set, traversing this result set with
a data reader will only ever have a single record loaded in memory at a given time.”
There are many flavours of transactions to choose from, writes Malik, listing out the same
‘in an increasing order of management overhead and decreasing order of performance’.
The list begins with implicit transactions, which are automatically associated with any
single SQL statement and ensure “the sanctity of the data during that statement’s execution
time period,” and ends with “storing a snapshot of previous data, which acts as your
`recovery contract’ and a flag on the `in doubt’ rows.”
Helpful notes are strewn all over the book. One such reads, “Retrieving a large volume of
data within the context of a single connection will always be faster than retrieving small
portions and opening and closing the connection each time, because large-block retrieval
causes less network roundtrips and incurs less latency.”
Useful for the ADO techie.
12.4 Summary
The Recordset object represents a set of records returned from a database query. It is used
to examine and manipulate data within a database. Combined with the cursor service, it
enables us to move through the records, find particular records that fit certain criteria, sort
records in a particular order, and update records.
A Recordset object allows us to access individual records and fields. The set of fields
associated with a recordset (and with each individual record) is accessible through the
Fields collection and Field object.
A Recordset can either exist on its own or be attached to a Connection. The latter is a
preferred option when we are creating several recordsets within a page, because it means
that the connection to the data doesn’t have to be opened each time we create a recordset.
We can either update record in records in a recordset one record at a time, or we can batch
a set of changes to various records, and then execute database update in one step.
Recordset objects can also be disconnected from a data store, so that changes can be made
to the data in an off-line state, and then updated when the recordset is reconnected to the
database. This allows for the movement of entire recordsets from the server to client for
update and manipulation.
LOVELY PROFESSIONAL UNIVERSITY 279