Introduction
DAO database library DLL
I have noticed that working with DAO databases and recordsets can often be
tedious and time consuming, which is why I created this DAO database library.
My goal was to create a library to speed up coding time when working with DAO.
My classes inherit from the base DAO classes so no functionality is lost.
My library allows you to
- quickly open database and recordset objects,
- close them quickly without worrying about memory leaks,
- easily read and write from the database for specific data types.
These functions are not intended to replace CDaoDatabase
/CDaoRecordset
functionality,
but rather extend them for reduced coding.
I. DLL Setup
1. Open the project and compile the DLL using "rebuild all",
it will create a .dll and .lib file for you in your release folder.
II. Client EXE Setup
- In project -> settings -> link -> object libraries
include daolibrary.lib
- In Release folder add daolibrary.dll
- In project workspace add daolibrary.lib
- Add dllHeader.h to project and following
lines in client .cpp file.
#include "dllHeader.h"
CDaoDB db;
CDaoRS rs;
Functions available:
CDaoDB Documentation
Class CDaoDB extends the CDaoDatabase class
bool CDaoDB::dbOpen(CString strFilePathName);
Opens connection to CDaoDatabase
given a
database filename with path.
bool CDaoDB::dbClose();
Closes the CDaoDatabase
, deletes variables
to prevent memory leaking.
CString CDaoDB::GetTableName(int tableNum);
Returns the name of a table based on
the table number.
CDaoRS Documentation
Class CDaoRS extends the CDaoRecordset class
bool CDaoRS::rsOpen(CString sql,CDaoDatabase* db);
Opens connection to CDaoRecordset given sql
and database.
i.e.
rs.rsOpen("SELECT * FROM TABLE",database.db);
*note that this opens the recordset as dbOpenDynaset
bool CDaoRS::rsClose();
Closes the CDaoRecordset
, deletes variables
to prevent memory leaking.
double CDaoRS::GetAsDouble(int col);
Returns a double value from the specified
column in the recordset.
int CDaoRS::GetAsInt(int col);
Returns an int value from the specified
column in the recordset.
long CDaoRS::GetAsLong(int col);
Returns a long value from the specified
column in the recordset.
CString CDaoRS::GetAsString(int col);
Returns a long value from the specified
column in the recordset.
CString CDaoRS::GetDateAsString(int col);
Returns a date value in CString format from
the specified column in the recordset. The
CString
will be returned with mm/dd/yyy format.
CString CDaoRS::GetTimeAsString(int col);
Returns a date value in CString format from
the specified column in the recordset. The
CString
will be returned with hh:mm:ss format.
void CDaoRS::SetAsString(CString field,CString string);
Set specified fieldname field in recordset to
the CString
value string.
void CDaoRS::SetAsInt(CString field,int integer);
Set specified fieldname field in recordset to
the integer value int.
void CDaoRS::SetAsLong(CString field,long lngValue);
Set specified fieldname field in recordset to
the long value lngValue
.
void CDaoRS::SetAsDouble(CString field,double dblValue);
Set specified fieldname field in recordset to
the double value dblValue
.
CString CDaoRS::GetFieldName(int col);
Returns the field name of the specified column
number in the recordset.
int CDaoRS::GetRecordCount();
Returns the number of records in the
recordset.
Please give suggestions for other functions you would like to see in here.
Sample client app will be available soon...