Click here to Skip to main content
Click here to Skip to main content

DAO library extension

, 4 Mar 2002
Rate this:
Please Sign up or sign in to vote.
My added DAO functionality makes database reading and writing easier
<!-- Download Links --> <!-- Add the rest of your HTML here -->

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 

  1. quickly open database and recordset objects,
  2. close them quickly without worrying about memory leaks, 
  3. 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

  1. In project -> settings -> link -> object libraries include daolibrary.lib 
  2. In Release folder add daolibrary.dll 
  3. In project workspace add daolibrary.lib 
  4. Add dllHeader.h to project and following lines in client .cpp file.
#include "dllHeader.h" 
CDaoDB db; // database 
CDaoRS rs; // recordset

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...

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Kevin Smith
Web Developer
United States United States
Software developer, for Interactive Metronome (http://www.interactivemetronome.com).
 
BA Computer Science, Calvin College

Comments and Discussions

 
Generalreport error Pinmemberewighell29-Oct-05 3:32 
Generaldatabase.Create() generates 97 db format Pinmembergeneral.failure14-Jul-03 2:13 
GeneralRe: database.Create() generates 97 db format PinsussAnonymous14-Jul-03 5:09 
GeneralRe: database.Create() generates 97 db format PinsussAnonymous20-Jul-03 2:33 
GeneralDAO Crash PinmemberRLupan25-Feb-03 3:28 
GeneralSample client app 's needed. Pinmembermak6-May-02 21:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web03 | 2.8.140721.1 | Last Updated 5 Mar 2002
Article Copyright 2002 by Kevin Smith
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid