BOOL GetFieldData(int nField, CString& strRet, BOOL bConvertMemo = TRUE);
nField
Specifies a zero-based field index.
strRet
A reference to a CString to store the field data.
bConvertMemo
TRUE if LONGBINARY data (typically Memo fields) should be converted to strings; FALSE if they should be ignored.
TRUE if operation was successful; FALSE otherwise.
Retrieves field data from the current record. The data will be returned as CString.
You can use GetFieldData to dynamically fetch fields at run time. Use SetFieldData to change data in the current record.
If you have declared a CGXDynamicRecordset object, you can use GetFieldData to retrieve the field data. The following sample code illustrates this case:
// Create a database object
CDatabase db;
// Create and open a recordset object
CGXDynamicRecordset rs( &db );
rs.SetSqlQuery( _T("Select * from student") );
rs.Open( );
// Loop through the recordset and display all field values in a row
rs.MoveFirst();
while (!rs.IsEOF())
{
for (UINT nField = 0; nField < rs.m_nFields; nField++)
{
CString s;
if (rs.GetFieldData(nField, s))
TRACE(_T("\042%s\042"), s);
if (nField < rs. m_nFields-1)
TRACE(_T(", "));
else
TRACE(_T("\n"));
}
rs.MoveNext( );
}
rs.Close( );
db.Close( );
CGXDynamicRecordset::SetFieldData
Class Overview | Class Members