CDAORECORDSET Class / DAO method is used to operate databases in VC 7.0
There is no operation as the CDAORECORDSET as VC 6.0, can only manually write the inheritance class of CDAORECordSet, and rewrite some functions, although some DAO record set is difficult, but DAO itself is a good database access. Mode, very convenient
First add classes, because CDAORECORDSETs are provided in the base class of VC 7.0, so only the general C class can be added, and the base class is written to CDAORECORDSET.
Set class named CDATA to rewrite the following functions in class properties
GetDefaultdbname () getDefaultsql () DofieldExchange (CDAOFieldExchange * PFX)
GetDefaultDbname () Returns the database file location getDefaultsql () Back to the table name
DofieldExchange (CDAOFIELDEXCHANGE * PFX)
PFX-> setfieldType (CDAOFIELDEXCHANGE :: OutputColumn); DFX_Text (PFX, _T ("Column1"), M_Column1); CDAORECORDSET :: DofieldExchange (PFX);
Where DFX_Text (PFX, _T ("Column1"), M_COLUMN1), the column1 in _t ("Column1") is the column name in the data table, m_column1 is corresponding to the corresponding variable, DFX_Text is limited to cstring, other types can be checked DFX macro [reference msdn]
CDATA constructor needs to be overwritten, cdata :: cdatabasezhiwei (CDAODATABASE * PDB): CDAORECORDSET (PDB) {m_column1 = _t ("); m_nfields = 1; m_ndefaulttype = dbopendynaset;}
M_Column is the initialization of the variable, m_nfields is the number of columns, m_ndefaulttype is the type of table.
In this way, CDATA is a recordset of CDAORECordSet