CDaoRecordset Class
Represents a set of records selected from a data source.
class CDaoRecordset : public CObject
Members
Public Constructors
Name |
Description |
---|---|
Constructs a CDaoRecordset object. |
Public Methods
Name |
Description |
---|---|
Prepares for adding a new record. Call Update to complete the addition. |
|
Returns nonzero if new records can be added to the recordset via the AddNew member function. |
|
Returns nonzero if the recordset supports bookmarks. |
|
Cancels any pending updates due to an Edit or AddNew operation. |
|
Returns nonzero if Requery can be called to run the recordset's query again. |
|
Returns nonzero if you can scroll through the records. |
|
Returns nonzero if the data source supports transactions. |
|
Returns nonzero if the recordset can be updated (you can add, update, or delete records). |
|
Closes the recordset. |
|
Deletes the current record from the recordset. You must explicitly scroll to another record after the deletion. |
|
Called to exchange data (in both directions) between the field data members of the recordset and the corresponding record on the data source. Implements DAO record field exchange (DFX). |
|
Prepares for changes to the current record. Call Update to complete the edit. |
|
Fills all or a part of a local cache for a recordset object that contains data from an ODBC data source. |
|
Locates the first, next, previous, or last location of a particular string in a dynaset-type recordset that satisfies the specified criteria and makes that record the current record. |
|
Locates the first record in a dynaset-type or snapshot-type recordset that satisfies the specified criteria and makes that record the current record. |
|
Locates the last record in a dynaset-type or snapshot-type recordset that satisfies the specified criteria and makes that record the current record. |
|
Locates the next record in a dynaset-type or snapshot-type recordset that satisfies the specified criteria and makes that record the current record. |
|
Locates the previous record in a dynaset-type or snapshot-type recordset that satisfies the specified criteria and makes that record the current record. |
|
Returns the record number of a recordset object's current record. |
|
Returns a value that represents the bookmark on a record. |
|
Returns a value that specifies the number of records in a dynaset-type recordset containing data to be locally cached from an ODBC data source. |
|
Returns a value that specifies the bookmark of the first record in the recordset to be cached. |
|
Returns a CString containing the name of the index most recently used on an indexed, table-type CDaoRecordset. |
|
Returns the date and time the base table underlying a CDaoRecordset object was created |
|
Returns the date and time of the most recent change made to the design of a base table underlying a CDaoRecordset object. |
|
Returns the name of the default data source. |
|
Called to get the default SQL string to execute. |
|
Returns a value that indicates the state of editing for the current record. |
|
Returns a value that represents the number of fields in a recordset. |
|
Returns specific kinds of information about the fields in the recordset. |
|
Returns the value of a field in a recordset. |
|
Retrieves the number of indexes in a table underlying a recordset. |
|
Returns various kinds of information about an index. |
|
Used to determine the most recently added or updated record. |
|
Returns a value that indicates the type of locking that is in effect during editing. |
|
Returns a CString containing the name of the recordset. |
|
Retrieves the current value of the specified parameter stored in the underlying DAOParameter object. |
|
Returns the position of the current record as a percentage of the total number of records. |
|
Returns the number of records accessed in a recordset object. |
|
Gets the SQL string used to select records for the recordset. |
|
Called to determine the type of a recordset: table-type, dynaset-type, or snapshot-type. |
|
Returns a CString containing the value that validates data as it is entered into a field. |
|
Retrieves the text that is displayed when a validation rule is not satisfied. |
|
Returns nonzero if the recordset has been positioned before the first record. There is no current record. |
|
Returns nonzero if the recordset is positioned on a deleted record. |
|
Returns nonzero if the recordset has been positioned after the last record. There is no current record. |
|
Returns nonzero if the specified field in the current record has been changed. |
|
Returns nonzero if the specified field in the current record is Null (having no value). |
|
Returns nonzero if the specified field in the current record can be set to Null (having no value). |
|
Returns nonzero if Open has been called previously. |
|
Positions the recordset to a specified number of records from the current record in either direction. |
|
Positions the current record on the first record in the recordset. |
|
Positions the current record on the last record in the recordset. |
|
Positions the current record on the next record in the recordset . |
|
Positions the current record on the previous record in the recordset. |
|
Creates a new recordset from a table, dynaset, or snapshot. |
|
Runs the recordset's query again to refresh the selected records. |
|
Locates the record in an indexed table-type recordset object that satisfies the specified criteria for the current index and makes that record the current record. |
|
Sets the record number of a recordset object's current record. |
|
Positions the recordset on a record containing the specified bookmark. |
|
Sets a value that specifies the number of records in a dynaset-type recordset containing data to be locally cached from an ODBC data source. |
|
Sets a value that specifies the bookmark of the first record in the recordset to be cached. |
|
Called to set an index on a table-type recordset. |
|
Marks the specified field in the current record as changed. |
|
Sets the value of the specified field in the current record to Null (having no value). |
|
Sets the value of a field in a recordset. |
|
Sets the value of a field in a recordset to Null. (having no value). |
|
Sets a value that indicates the type of locking to put into effect during editing. |
|
Sets the current value of the specified parameter stored in the underlying DAOParameter object |
|
Sets the current value of the specified parameter to Null (having no value). |
|
Sets the position of the current record to a location corresponding to a percentage of the total number of records in a recordset. |
|
Completes an AddNew or Edit operation by saving the new or edited data on the data source. |
Public Data Members
Name |
Description |
---|---|
Contains a flag indicating whether fields are automatically marked as changed. |
|
Contains the number of field data members in the recordset class and the number of columns selected by the recordset from the data source. |
|
Contains the number of parameter data members in the recordset class — the number of parameters passed with the recordset's query |
|
A pointer to the DAO interface underlying the recordset object. |
|
Source database for this result set. Contains a pointer to a CDaoDatabase object. |
|
Contains a string used to construct a SQL WHERE statement. |
|
Contains a string used to construct a SQL ORDER BY statement. |
Remarks
Known as "recordsets," CDaoRecordset objects are available in the following three forms:
Table-type recordsets represent a base table that you can use to examine, add, change, or delete records from a single database table.
Dynaset-type recordsets are the result of a query that can have updateable records. These recordsets are a set of records that you can use to examine, add, change, or delete records from an underlying database table or tables. Dynaset-type recordsets can contain fields from one or more tables in a database.
Snapshot-type recordsets are a static copy of a set of records that you can use to find data or generate reports. These recordsets can contain fields from one or more tables in a database but cannot be updated.
Each form of recordset represents a set of records fixed at the time the recordset is opened. When you scroll to a record in a table-type recordset or a dynaset-type recordset, it reflects changes made to the record after the recordset is opened, either by other users or by other recordsets in your application. (A snapshot-type recordset cannot be updated.) You can use CDaoRecordset directly or derive an application-specific recordset class from CDaoRecordset. You can then:
Scroll through the records.
Set an index and quickly look for records using Seek (table-type recordsets only).
Find records based on a string comparison: "<", "<=", "=", ">=", or ">" (dynaset-type and snapshot-type recordsets).
Update the records and specify a locking mode (except snapshot-type recordsets).
Filter the recordset to constrain which records it selects from those available on the data source.
Sort the recordset.
Parameterize the recordset to customize its selection with information not known until run time.
Class CDaoRecordset supplies an interface similar to that of class CRecordset. The main difference is that class CDaoRecordset accesses data through a Data Access Object (DAO) based on OLE. Class CRecordset accesses the DBMS through Open Database Connectivity (ODBC) and an ODBC driver for that DBMS.
Note
The DAO database classes are distinct from the MFC database classes based on Open Database Connectivity (ODBC). All DAO database class names have the "CDao" prefix. You can still access ODBC data sources with the DAO classes; the DAO classes generally offer superior capabilities because they are specific to the Microsoft Jet database engine.
You can either use CDaoRecordset directly or derive a class from CDaoRecordset. To use a recordset class in either case, open a database and construct a recordset object, passing the constructor a pointer to your CDaoDatabase object. You can also construct a CDaoRecordset object and let MFC create a temporary CDaoDatabase object for you. Then call the recordset's Open member function, specifying whether the object is a table-type recordset, a dynaset-type recordset, or a snapshot-type recordset. Calling Open selects data from the database and retrieves the first record.
Use the object's member functions and data members to scroll through the records and operate on them. The operations available depend on whether the object is a table-type recordset, a dynaset-type recordset, or a snapshot-type recordset, and whether it is updateable or read-only — this depends on the capability of the database or Open Database Connectivity (ODBC) data source. To refresh records that may have been changed or added since the Open call, call the object's Requery member function. Call the object's Close member function and destroy the object when you finish with it.
CDaoRecordset uses DAO record field exchange (DFX) to support reading and updating of record fields through type-safe C++ members of your CDaoRecordset or CDaoRecordset-derived class. You can also implement dynamic binding of columns in a database without using the DFX mechanism using GetFieldValue and SetFieldValue.
For related information, see the topic "Recordset Object" in DAO Help.
Inheritance Hierarchy
CDaoRecordset
Requirements
Header: afxdao.h