void CODBCRecordset::DoFieldExchange( CFieldExchange* pFX ) { pFX->SetFieldType( CFieldExchange::outputColumn ); CString cFieldName; for( UINT i = 0; i < m_nFields; i++ ) { cFieldName.Format( "[%s]", GetFieldName(i) ); switch( m_fields[i].m_dwType ) { case DBVT_NULL: break; case DBVT_BOOL: RFX_Bool( pFX, cFieldName, m_fields[i].m_boolVal ); break; case DBVT_UCHAR: RFX_Byte( pFX, cFieldName, m_fields[i].m_chVal ); break; case DBVT_SHORT: // CDBVariant::m_iVal is of type short // RFX_Int() requires parameter of type int. // Class wizard maps int variable in this case // but CDBVariand does not have int member. m_fields[i].m_dwType = DBVT_LONG; RFX_Long( pFX, cFieldName, m_fields[i].m_lVal ); break; case DBVT_LONG: RFX_Long( pFX, cFieldName, m_fields[i].m_lVal ); break; case DBVT_SINGLE: RFX_Single( pFX, cFieldName, m_fields[i].m_fltVal ); break; case DBVT_DOUBLE: RFX_Double( pFX, cFieldName, m_fields[i].m_dblVal ); break; case DBVT_DATE: RFX_Date( pFX, cFieldName, *m_fields[i].m_pdate ); break; case DBVT_STRING: { CODBCFieldInfo fi; GetODBCFieldInfo( i, fi ); RFX_Text( pFX, cFieldName, *m_fields[i].m_pstring, fi.m_nPrecision ); break; } case DBVT_BINARY: RFX_LongBinary( pFX, cFieldName, *(m_fields[i].m_pbinary) ); break; default: // Unknown datatype ASSERT( FALSE ); } m_fields[i].SetNull( FALSE != IsFieldStatusNull( i ) ); } }
// Called by Move() to load info about all the fields void CODBCRecordset::LoadFieldNamesMap() { m_mapNameIdx.RemoveAll(); int nFields = m_nFields = GetODBCFieldCount(); // Smart storage reallocation for the fields buffer if( m_AllocatedFields < nFields ) { Clear(); m_fields = new CDBField[ m_nFields ]; m_AllocatedFields = m_nFields; } // Load field names map CODBCFieldInfo fi; CString cName; for( int i = 0; i < nFields; i++ ) { // Clear the previously allocated storage object m_fields[i].Clear(); // Determine the field type and initialize the data buffer GetODBCFieldInfo( i, fi ); AllocDataBuffer( m_fields[i], fi ); // Set the field name fi.m_strName.MakeUpper(); cName = fi.m_strName; // Make different field names for the fields with // equal names. int fldCount = 1; while( GetFieldID( cName ) != -1 ) { fldCount++; cName.Format( "%s%d", fi.m_strName, fldCount ); } m_fields[i].m_cName = cName; m_mapNameIdx.SetAt( cName, (void*)i ); } }
void CCurRecordset::PreBindFields() { WBOUT << "Binding Field columns..." << endl; const auto nCount = GetODBCFieldCount(); WBOUT << "Total ODBCFieldCount :" << nCount << endl; for (auto nCol = 0; nCol < nCount; nCol++) { CODBCFieldInfo info; GetODBCFieldInfo(nCol, info); WBOUT << "Fieldname = " << static_cast<LPCTSTR>(info.m_strName) << endl; m_listNames.AddTail(info.m_strName); m_listValues.AddTail(CString("n",255)); } m_nFields = nCount; // CRecordset::AllocStatusArrays(); WBOUT << "Fields bounded successfully..." << endl; }