CRecordset::SetFieldNull

void SetFieldNull( void* pv, BOOL bNull = TRUE );

Parameters

pv

Contains the address of a field data member in the recordset or NULL. If NULL, all field data members in the recordset are flagged. (C++ NULL is not the same as Null in database terminology, which means “having no value.”)

bNull

Nonzero if the field data member is to be flagged as having no value (Null). Otherwise 0 if the field data member is to be flagged as non-Null.

Remarks

Call this member function to flag a field data member of the recordset as Null (specifically having no value) or as non-Null. When you add a new record to a recordset, all field data members are initially set to a Null value and flagged as “dirty” (changed). When you retrieve a record from a data source, its columns either already have values or are Null.

Note   Do not call this member function on recordsets that are using bulk row fetching. If you have implemented bulk row fetching, calling SetFieldNull results in a failed assertion. For more information about bulk row fetching, see the article Recordset: Fetching Records in Bulk (ODBC) in Visual C++ Programmer’s Guide.

If you specifically wish to designate a field of the current record as not having a value, call SetFieldNull with bNull set to TRUE to flag it as Null. If a field was previously marked Null and you now want to give it a value, simply set its new value. You do not have to remove the Null flag with SetFieldNull. To determine whether the field is allowed to be Null, call IsFieldNullable.

Important   Call this member function only after you have called Edit or AddNew.

Using NULL for the first argument of the function will apply the function only to outputColumns, not params. For instance, the call

SetFieldNull( NULL );

will set only outputColumns to NULL. Params will be unaffected.

To work on params, you must supply the actual address of the individual param you want to work on, such as:

SetFieldNull( &m_strParam );

This means you cannot set all params NULL, as you can with outputColumns.

Note   When setting parameters to Null, a call to SetFieldNull before the recordset is opened results in an assertion. In this case, call SetParamNull.

SetFieldNull is implemented through DoFieldExchange.

CRecordset OverviewClass MembersHierarchy Chart

See Also   CRecordset::IsFieldNull, CRecordset::SetFieldDirty, CRecordset::Edit, CRecordset::Update, CRecordset::IsFieldNullable