CDaoRecordset::GetFieldValue

virtual void GetFieldValue( LPCTSTR lpszName, COleVariant& varValue );
throw( CDaoException, CMemoryException );

virtual void GetFieldValue( int nIndex, COleVariant& varValue );
throw( CDaoException, CMemoryException );

virtual COleVariant GetFieldValue( LPCTSTR lpszName );
throw( CDaoException, CMemoryException );

virtual COleVariant GetFieldValue( int nIndex );
throw( CDaoException, CMemoryException );

Return Value

The two versions of GetFieldValue that return a value return a COleVariant object that contains the value of a field.

Parameters

lpszName

A pointer to a string that contains the name of a field.

varValue

A reference to a COleVariant object that will store the value of a field.

nIndex

A zero-based index of the field in the recordset’s Fields collection, for lookup by index.

Remarks

Call this member function to retrieve data in a recordset. You can look up a field by name or by ordinal position.

Note   It is more efficient to call one of the versions of this member function that takes a COleVariant object reference as a parameter, rather than calling a version that returns a COleVariant object.

Use GetFieldValue and SetFieldValue to dynamically bind fields at run time rather than statically binding columns using the DoFieldExchange mechanism.

GetFieldValue and the DoFieldExchange mechanism can be combined to improve performance. For example, use GetFieldValue to retrieve a value that you need only on demand, and assign that call to a “More Information” button in the interface.

For more information about binding fields dynamically, see the article DAO Recordset: Binding Records Dynamically in Visual C++ Programmer's Guide. For related information, see the topics "Field Object" and "Value Property" in DAO Help.

CDaoRecordset OverviewClass MembersHierarchy Chart

See Also   CDaoRecordset::SetFieldValue