Share via


CFieldExchange::SetFieldType

You need a call to SetFieldType in your recordset class's DoFieldExchange or DoBulkFieldExchange override.

void SetFieldType( 
   UINT nFieldType  
);

Parameters

  • nFieldType
    A value of the enum FieldType, declared in CFieldExchange, which can be one of the following:

    • CFieldExchange::outputColumn

    • CFieldExchange::inputParam

    • CFieldExchange::param

    • CFieldExchange::outputParam

    • CFieldExchange::inoutParam

Remarks

For field data members, you must call SetFieldType with a parameter of CFieldExchange::outputColumn, followed by calls to the RFX or Bulk RFX functions. If you have not implemented bulk row fetching, then ClassWizard places this SetFieldType call for you in the field map section of DoFieldExchange.

If you parameterize your recordset class, you must call SetFieldType again, outside any field map section, followed by RFX calls for all the parameter data members. Each type of parameter data member must have its own SetFieldType call. The following table distinguishes the different values you can pass to SetFieldType to represent the parameter data members of your class:

SetFieldType parameter value

Type of parameter data member

CFieldExchange::inputParam

Input parameter. A value that is passed into the recordset's query or stored procedure.

CFieldExchange::param

Same as CFieldExchange::inputParam.

CFieldExchange::outputParam

Output parameter. A return value of the recordset's stored procedure.

CFieldExchange::inoutParam

Input/output parameter. A value that is passed into and returned from the recordset's stored procedure.

In general, each group of RFX function calls associated with field data members or parameter data members must be preceded by a call to SetFieldType. The nFieldType parameter of each SetFieldType call identifies the type of the data members represented by the RFX function calls that follow the SetFieldType call.

For more information about handling output and input/output parameters, see the CRecordset member function FlushResultSet. For more information about the RFX and Bulk RFX functions, see the topic Record Field Exchange Functions. For related information about bulk row fetching, see the article Recordset: Fetching Records in Bulk (ODBC).

Example

This example shows several calls to RFX functions with accompanying calls to SetFieldType. Note that SetFieldType is called through the pFX pointer to a CFieldExchange object.

void CSections::DoFieldExchange(CFieldExchange* pFX)
{
    pFX->SetFieldType(CFieldExchange::outputColumn);
    RFX_Text(pFX, _T("[CourseID]"), m_CourseID);
    RFX_Text(pFX, _T("[InstructorID]"), m_InstructorID);
    RFX_Text(pFX, _T("[RoomNo]"), m_RoomNo);
    RFX_Text(pFX, _T("[Schedule]"), m_Schedule);

   // output parameter
   pFX->SetFieldType(CFieldExchange::outputParam);
   RFX_Long(pFX, _T("Instructor_Count"), m_nCountParam);

   // input parameter
   pFX->SetFieldType(CFieldExchange::inputParam);
   RFX_Text(pFX, _T("Department_Name"), m_strNameParam);
}

Requirements

Header: afxdb.h

See Also

Reference

CFieldExchange Class

Hierarchy Chart

CRecordset::DoFieldExchange

CRecordset::DoBulkFieldExchange

CRecordset::FlushResultSet

Other Resources

Record Field Exchange Functions