CdbField Object

See Also   Methods   Properties

A CdbField object represents a column of data with a common data type and a common set of properties.








Remarks

The Fields collections of CdbIndex, CdbQueryDef, CdbRelation, and CdbTableDef objects contain the specifications for the fields those objects represent. The Fields collection of a CdbRecordset object represents the CdbField objects in a row of data or in a record. Use the CdbField objects in a CdbRecordset object to read and set values for the fields in the current record of the CdbRecordset object.

In both Microsoft Jet and ODBCDirect workspaces, you manipulate a field using a CdbField object and its methods and properties. For example, you can:

In Microsoft Jet workspaces, you can:

In ODBCDirect workspaces, you can:

To create a new CdbField object in a CdbIndex, CdbTableDef, or CdbRelation object, use the CreateField method.

When you access a CdbField object as part of a CdbRecordset object, data from the current record is visible in the CdbField object's Value property. To manipulate data in the CdbRecordset object, you don't usually reference the Fields collection directly; instead, you indirectly reference the Value property of the CdbField object in the Fields collection of the CdbRecordset object.

To refer to a CdbField object in a collection by its ordinal number or by its Name property setting, use either of the following syntax forms:

Fields[0]

Fields["name"]

With the same syntax forms, you can also refer to the Value property of a CdbField object that you create and append to a Fields collection. The context of the field reference will determine whether you are referring to the CdbField object or the Value property of the CdbField object.

CdbField Constructor Syntax

Use any one of the following three constructors. The qualifier 'CONSTRUCTOR' in the syntax models is provided to help readability. It has no syntactic value.

CONSTRUCTORCdbField(VOID);

This constructor creates an instance of the class. There are no parameters.

CONSTRUCTORCdbField(const CdbField &);

Type Description
const CdbField & Reference to an object.

This constructor creates a copy of the object referenced in the parameter.

CONSTRUCTORCdbField(DAOField *pfld,

BOOL bAddRef = FALSE);

Type Argument Description
DAOField * pfld A DAO Automation interface pointer corresponding to this DAO class.
BOOL bAddRef

=FALSE

Optional. A Boolean. If TRUE,

the DAO Automation interface AddRef function is called.


DAO functionality is presented through pointers to DAO Automation interfaces. This constructor makes a DAO interface available in the form of a DAO class object that provides additional functionality.

This constructor is not required for typical use. It is provided to enable you to easily create a DAO class object if you have access to the corresponding DAO interface.

When the destructor for the DAO object is invoked, the underlying Automation interface's Release member is called. If Release decrements the interface's reference count to zero, the pointer to the Automation interface can be deleted. If you don't want this to happen (for example, because you want to discard the DAO object, but continue using the Automation interface), specify TRUE for the second parameter. The underlying Automation interface's AddRef member is called, which counterbalances the eventual call to Release.