CFieldExchange::SetFieldType

void SetFieldType( UINT nFieldType );

Parameters

nFieldType

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

Remarks

You need a call to SetFieldType in your recordset class's DoFieldExchange or DoBulkFieldExchange override. 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) in Visual C++ Programmer's Guide.

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 )
{
   //{{AFX_FIELD_MAP(CSections)
   pFX->SetFieldType( CFieldExchange::outputColumn );
   RFX_Text( pFX, "CourseID", m_strCourseID );
   RFX_Text( pFX, "InstructorID", m_strInstructorID );
   RFX_Text( pFX, "RoomNo", m_strRoomNo );
   RFX_Text( pFX, "Schedule", m_strSchedule );
   //}}AFX_FIELD_MAP

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

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

CFieldExchange OverviewClass MembersHierarchy Chart

See Also   CRecordset::DoFieldExchange, CRecordset::DoBulkFieldExchange, CRecordset::FlushResultSet, Record Field Exchange Functions