parent nodes: ArchivosYClases | CambiarPunterosPorVariablesLocales
CInDaoRecordset
Proyecto: inclacol
Archivos: inclacolInDaoClases.h inclacolInDaoClases.cpp
Constructor: CInDaoRecordset(CInDaoDatabase* pDatabase = NULL);
Crear un RecordSet sin usar punteros
Para no ir moviendo el heap de memoria sin necesidad. Sí en la misma función hacemos el new y el delete o, lo que es lo mismo, el CreateRecordset y el BorraDaoPuntero estamos usando la memoria sin necesidad, se puede hacer lo mismo en el stack de memoria.try
{
CInDaoRecordset rsDatos(db); // constructor si db no existe usar DameGen()->m_dbgeneral
rsDatos.Open(dbOpenDynaset, strSQL, dbReadOnly); // ver más abajo detalle de Open
if(rsDatos.IsBOF() && rsDatos.IsEOF())
{
AfxThrowDBException( SQL_ERROR, NULL, NULL );
}
if(!rsDatos.IsBOF())
rsDatos.MoveFirst();
//(···)
if( rsDatos.IsOpen() == TRUE )
rsDatos.Close();
}
catch( CDaoException * e )
{
e->ReportError();
DaMensaje( IDS_SQL_MENSAJE_TEMPORALES, IDS_SQL_MENSAJE_TEMPORALES, MEN_INFOR );
delete e;
return FALSE;
}
return true;
CDaoRecordset::Open
virtual void Open( int nOpenType = AFX_DAO_USE_DEFAULT_TYPE, LPCTSTR lpszSQL = NULL, int nOptions = 0 );
virtual void Open( CDaoTableDef * pTableDef, int nOpenType = dbOpenTable, int nOptions = 0 );
virtual void Open( CDaoQueryDef * pQueryDef, int nOpenType = dbOpenDynaset, int nOptions = 0 );
nOpenType One of the following values:dbOpenDynaset A dynaset-type recordset with bidirectional scrolling. This is the default.
dbOpenTable A table-type recordset with bidirectional scrolling.
dbOpenSnapshot A snapshot-type recordset with bidirectional scrolling.
nOptions One or more of the options listed below. The default value is 0. Possible values are as follows:dbAppendOnly You can only append new records (dynaset-type recordset only). This option means literally that records may only be appended. The MFC ODBC database classes have an append-only option that allows records to be retrieved and appended.
dbForwardOnly The recordset is a forward-only scrolling snapshot.
dbSeeChanges Generate an exception if another user is changing data you are editing.
dbDenyWrite Other users cannot modify or add records.
dbDenyRead Other users cannot view records (table-type recordset only).
dbReadOnly You can only view records; other users can modify them.
dbInconsistent Inconsistent updates are allowed (dynaset-type recordset only).
dbConsistent Only consistent updates are allowed (dynaset-type recordset only).
[camelCaseWordsEnabled: false]