Recordset Object
A Recordset object represents the entire set of records from a base
table or the results of an executed command. At any time, the Recordset
object only refers to a single record within the set as the current record.



Collections
Fields, Properties
Properties
AbsolutePage, AbsolutePosition,
ActiveConnection, BOF,
Bookmark, CacheSize,
CursorType, EditMode,
EOF, Filter, LockType,
MaxRecords, PageCount,
PageSize, RecordCount,
Source, Status
Methods
AddNew, CancelBatch,
CancelUpdate, Clone,
Close, Delete, GetRows,
Move, MoveFirst, MoveLast,
MoveNext, MovePrevious,
NextRecordset, Open,
Requery, Resync, Supports,
Update, UpdateBatch
Remarks
You can create Recordset objects independently of a previously defined Connection
object by passing a connection string with the Open
method. ADO still creates a Connection object, but it doesn't
assign that object to an object variable. However, if you are opening multiple
Recordset objects over the same connection, you should explicitly
create and open a Connection object; this assigns the Connection
object to an object variable. If you do not use this object variable when
opening your Recordset objects, ADO creates a new Connection
object for each new Recordset object, even if you pass the same
connection string.
You use Recordset objects to manipulate data from a provider at the
record level. When you use ADO, you manipulate data almost entirely using Recordset
objects. All Recordset objects are constructed using records (rows) and
fields (columns). Depending on the functionality the provider exposes, some
collections, methods, or properties of a Recordset object may not be
available.
You can use one of four different cursor types when opening a Recordset
object:
· Dynamic cursor ¾ allows you to view additions, changes, and deletions by
other users, and allows all types of movement through the Recordset
that don't rely on bookmarks; allows bookmarks if the provider supports
them.
· Keyset cursor ¾ behaves like a dynamic cursor, except that it prevents
you from seeing records that other users add, and prevents access to records
that other users delete from your recordset; always allows bookmarks and
therefore allows all types of movement through the Recordset. Data
changes by other users will still be visible.
· Static cursor ¾ provides a static copy of a set of records for you to
use to find data or generate reports; always allows bookmarks and therefore
allows all types of movement through the Recordset. Additions, changes,
or deletions by other users will not be visible.
· Forward-only cursor ¾ behaves identically to a static cursor except that it
allows you to scroll only forward through records. This improves performance
in situations where you need to make only a single pass through a recordset.
Set the CursorType property prior to opening
the Recordset object to choose the cursor type of the Recordset
object. You can also pass a CursorType argument with the Open
method.
If you don't specify a cursor type, ADO opens a forward-only cursor by
default.
You can create as many Recordset objects as needed. Different Recordset
objects can access the same tables and fields without conflicting.
When you create a Recordset object, the current record is positioned to
the first record (if any) and the BOF and EOF
properties are set to False. If there are no records, the RecordCount
property setting is 0, and the BOF and EOF property settings are
True.
You can use the MoveFirst, MoveLast,
MoveNext, and MovePrevious
methods, as well as the Move method, and the AbsolutePosition,
AbsolutePage, and Filter
properties to reposition the current record, assuming the provider supports
the relevant functionality. Forward-only Recordset objects support only
the MoveNext method. When you use the Move methods to visit each
record (or enumerate the Recordset), you can use the BOF and EOF
properties to see if you've moved beyond the beginning or end of the Recordset
object.
Recordset objects may support two types of updating: immediate and
batched. In immediate updating, all changes to data are written immediately to
the underlying data source once you call the Update
method. You can also pass arrays of values as parameters with the AddNew
and Update methods and simultaneously update several fields in a
record.
If a provider supports batch updating, you can have the provider cache changes
to more than one record and then transmit them in a single call to the
database with the UpdateBatch method. This
applies to changes made with the AddNew, Update, and Delete
methods. After you call the UpdateBatch method, you can use the Status
property to check for any data conflicts in order to resolve them.
Note You should use batch updating only with either a keyset or static
cursor.
See Also
Connection
|