Introduction
This classes is useful for work with dbf files. The current version supports formats:
FoxPro, Visual FoxPro, dBASEIII - dBASE 5.x, Clipper and HiPer-SIx. The memo fields also
are supported. CDBFRecordset
provides all the useful functions for navigation
and modification in table. CDBFCursorset
it is possible to use for work only
with the selected records. CDBFTableDef
it is used for creation and updating
of structure of the table.
Create/Update table structure
For creation/updating of structure of the table are available functions:
<li><code>CreateTable
ModifyTable
AddField
InsertField
ModifyField
MoveField
DeleteField
UpdateTable
For cancels any pending updates you may call function CanselUpdateTable()
.
try
{
CDBFTableDef mNewTable;
mNewTable.CreateTable(szFileName);
FIELD_REC FieldRec;
memset(&FieldRec, 0, sizeof(FIELD_REC));
memcpy(FieldRec.field_name, szFieldName, 10);
FieldRec.field_type = FLD_TYPE_CHARACTER;
FieldRec.len_info.char_len = 20;
mNewTable.AddField(&FieldRec);
mNewTable.UpdateTable();
}
catch(CDBFException* e)
{
e->ReportError();
e->Delete();
}
Navigation
For navigation are supported functions:
<li><code>Move
MoveNext
MovePrev
MoveFirst
MoveLast
SetAbsolutePosition
You also may use functions: IsEOF()
, IsBOF()
,
GetRecordCount()
, GetAbsolutePosition()
.
try
{
CDBFRecordset m_Set;
m_Set.Open("test.dbf");
while(!m_Set.IsEOF())
{
m_Set.MoveNext();
}
}
catch(CDBFException* e)
{
e->ReportError();
e->Delete();
}
Append/Edit record
For addition, changes of record are functions:
<li><code>AddNew
Edit
SetFieldValue
Delete
Undelete
Update
You also may use functions: LockRecord()
, UnlockRecord()
,
GetFieldvalue()
.
try
{
m_Set.Edit();
m_Set.SetFieldValue("Key",varKey);
m_Set.SetFieldValue("NAME",varName);
m_Set.SetFieldValue("PHONE",varPhone);
m_Set.Update();
}
catch(CDBFException* e)
{
e->ReportError();
e->Delete();
}
Find Functions
For find are supported functions:
<li><code>FindFirst
FindNext
FindLast
FindPrev
try
{
BOOL bFind = m_Set.FindFirst("LIKE('*Club*', NAME)");
while(bFind)
{
bFind = m_Set.FindNext();
}
}
catch(CDBFException* e)
{
e->ReportError();
e->Delete();
}
Parameter of functions: FindFirst()
, FindLast()
,
...
string expression of dBASE language.
Filter
For the filter SetFilter
function is used:
try
{
m_Set.SetFilter("LIKE('*Club*', NAME)");
m_Set.Requery()
}
catch(CDBFException* e)
{
e->ReportError();
e->Delete();
}
This function is supported only in classes CDBFCursorset
and CDBFMemCursorset
.
DBFView Demo
This sample shows some opportunities of library alxBASE.
More information about the product can be found at http://www.alxsoft.narod.ru.