Opening a table
To access your dBase tables you should add Alchemy DBF Access files to your
project, create an instance of CDBFTable class and add the code that opens
your DBF table:
BOOL CDBFTable::Open(const char* sFileName);
Navigating thrue records
You can move the record pointer up and down thrue the data table:
BOOL CDBFTable::GoTop();
BOOL CDBFTable::GoBottom();
BOOL CDBFTable::GoToRecord(long recno);
BOOL CDBFTable::GoToNonDeletedRecord(long recno);
BOOL CDBFTable::Skip(long count = 1);
Reading data from the current record
Alchemy DBF Access allows you to read data from the table using various
formats:
int CDBFTable::GetInt(const char* sFieldName);
BOOL CDBFTable::GetLogical(const char* sFieldName);
double CDBFTable::GetDouble(const char* sFieldName);
CString CDBFTable::GetString(const char* sFieldName);
CTime CDBFTable::GetDate(const char* sFieldName);
Writing data to the record
To write data to the current database record you should open the current record
for editing, write data to the table and then post written data to the database:
BOOL CDBFTable::Edit();
BOOL CDBFTable::PutInt(const char* pszFieldName, int iValue);
BOOL CDBFTable::PutLogical(const char* pszFieldName, BOOL bValue);
BOOL CDBFTable::PutDouble(const char* pszFieldName, double fValue);
BOOL CDBFTable::PutString
(
const char* sFieldName,
const char* sValue
);
BOOL CDBFTable::PutDateField(const char* sFieldName, CTime &dtValue);
BOOL CDBFTable::Post();
Insert/delete operations
You can insert and delete records from/to the table. Since deleted record in
DBase table is not immediatelly deleted from the file, you can either recall it
later or physically delete deleted records from the table with the help of the
pack operation:
BOOL CDBFTable::Append();
BOOL CDBFTable::Delete();
BOOL CDBFTable::Recall();
BOOL CDBFTable::Pack();
Closing the table
After you've finished working with CDBFTable, release allocated resources and
close opened table by calling:
BOOL CDBFTable::Close();
Resume
As you probably noted, Alchemy DBF Access provides extremely clear
and simple way for manipulating database tables; it does not require any
additional DLLs and adds only few kilobytes to your program. Just
download it and you can bring database power to your programs!