Click here to Skip to main content
11,413,676 members (69,333 online)
Click here to Skip to main content

The alxBase classes for work with DBF files

, 5 Nov 2002
Rate this:
Please Sign up or sign in to vote.
The alxBase classes for work with dbf files.

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;
	// begin create
	mNewTable.CreateTable(szFileName);

	// add field
	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);

	// ...

	// end create
	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:

    <li><code>SetFilter
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.

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

Share

About the Author

Alexey
Web Developer
Russian Federation Russian Federation
Year of birth - 1974.
Eeducation - was ended by Kaliningrad State University in 1997.
Now I work as the engineer-programmer in Kaliningrad (RUSSIA).

Comments and Discussions

 
QuestionAssertion Failed! Pin
Goa, 3-Jul-07 8:36
memberGoa3-Jul-07 8:36 
AnswerRe: Assertion Failed! Pin
Goa, 4-Jul-07 6:18
memberGoa4-Jul-07 6:18 
QuestionalxBase without mfc Pin
joviens, 19-Dec-06 6:44
memberjoviens19-Dec-06 6:44 
AnswerRe: alxBase without mfc Pin
S Mario, 26-Oct-09 19:08
memberS Mario26-Oct-09 19:08 
Generalfield content Pin
Joao Araujo, 21-Jan-06 16:51
memberJoao Araujo21-Jan-06 16:51 
GeneralDelete records Pin
pgiustinoni, 7-Jul-05 7:49
memberpgiustinoni7-Jul-05 7:49 
GeneralGood work But... Pin
ali TEKE, 11-Apr-05 4:37
memberali TEKE11-Apr-05 4:37 
GeneralProblem in adding new records Pin
Mr.V.Stephen, 30-Jan-05 0:04
memberMr.V.Stephen30-Jan-05 0:04 
GeneralRe: Problem in adding new records Pin
EndlessWinter, 10-Feb-05 17:18
memberEndlessWinter10-Feb-05 17:18 
GeneralIts really a very nice project Pin
vstephen2002, 22-Jan-05 0:37
membervstephen200222-Jan-05 0:37 
Its really a very nice project I have come across so far.Hats off to the author.But one suggestion.If an example project to create a dbf and append records into it had been included,it would have been really helpful to beginners like me.Also the settings for the project should be described in detail.
Awaiting your simple example project,

Stephen
India
GeneralUsing the FindFirst function Pin
Alex Evans, 1-Nov-04 12:14
memberAlex Evans1-Nov-04 12:14 
GeneralRe: Using the FindFirst function Pin
EndlessWinter, 10-Feb-05 17:23
memberEndlessWinter10-Feb-05 17:23 
GeneralConverted library for Windos CE Pin
Alex Evans, 2-Oct-04 22:53
memberAlex Evans2-Oct-04 22:53 
GeneralUsing this with Windows CE Pin
Alex Evans, 1-Oct-04 21:51
memberAlex Evans1-Oct-04 21:51 
GenerallockRecord() Pin
thangoftin2, 9-Aug-04 19:18
memberthangoftin29-Aug-04 19:18 
GeneralUsing the FindFirst function Pin
Alex Evans, 1-Nov-04 12:17
memberAlex Evans1-Nov-04 12:17 
QuestionHow can i insert/update/delete image file? Pin
Mr.Ahn, 7-Jul-04 2:21
memberMr.Ahn7-Jul-04 2:21 
QuestionHow to pack deleted record Pin
simranjeet, 11-Jun-04 4:08
membersimranjeet11-Jun-04 4:08 
AnswerRe: How to pack deleted record Pin
Alexey, 14-Jun-04 20:28
memberAlexey14-Jun-04 20:28 
QuestionHow to pack deleted record Pin
simranjit, 11-Jun-04 4:02
susssimranjit11-Jun-04 4:02 
QuestionSample db files? Pin
chenhuisheng, 13-Apr-04 16:21
memberchenhuisheng13-Apr-04 16:21 
GeneralGreat!! - one question Pin
bdiamond, 29-Mar-04 4:30
memberbdiamond29-Mar-04 4:30 
GeneralRe: Great!! - one question Pin
Alexey, 29-Mar-04 19:33
memberAlexey29-Mar-04 19:33 
Generalcan't write header info correctly Pin
bdiamond, 18-Mar-04 8:10
memberbdiamond18-Mar-04 8:10 
GeneralRe: can't write header info correctly Pin
Alexey, 18-Mar-04 20:42
memberAlexey18-Mar-04 20:42 
Generale:\temp\alxBASE\SRC\ALXParserFuncDef.cpp(1221): error C2666: &#8220;pow&#8221; : 7 overloads have the similar conversion Pin
Tom_lyd, 17-Dec-03 21:10
memberTom_lyd17-Dec-03 21:10 
GeneralRe: e:\temp\alxBASE\SRC\ALXParserFuncDef.cpp(1221): error C2666: ?pow? : 7 overloads have the similar conversion Pin
Dmitry Naumov, 21-Jan-04 22:14
memberDmitry Naumov21-Jan-04 22:14 
GeneralRe: e:\temp\alxBASE\SRC\ALXParserFuncDef.cpp(1221): error C2666: ?pow? : 7 overloads have the similar conversion Pin
m0xx, 22-Jun-04 22:57
memberm0xx22-Jun-04 22:57 
GeneralRe: e:\temp\alxBASE\SRC\ALXParserFuncDef.cpp(1221): error C2666: ?pow? : 7 overloads have the similar conversion Pin
shaunwerkhoven, 28-Sep-04 1:15
membershaunwerkhoven28-Sep-04 1:15 
GeneralRe: e:\temp\alxBASE\SRC\ALXParserFuncDef.cpp(1221): error C2666: ?pow? : 7 overloads have the similar conversion Pin
Ganjoo, 11-Oct-04 5:00
sussGanjoo11-Oct-04 5:00 
GeneralRe: e:\temp\alxBASE\SRC\ALXParserFuncDef.cpp(1221): error C2666: ?pow? : 7 overloads have the similar conversion Pin
Anthony_Yio, 18-May-05 0:11
memberAnthony_Yio18-May-05 0:11 
GeneralHelp, I'm a newbie Pin
arktow, 6-Nov-03 9:06
memberarktow6-Nov-03 9:06 
GeneralRe: Help, I'm a newbie Pin
Alexey, 9-Nov-03 20:53
memberAlexey9-Nov-03 20:53 
GeneralAssertion Failed! Pin
dade88888, 17-Oct-03 1:20
memberdade8888817-Oct-03 1:20 
GeneralRe: Assertion Failed! Pin
Alexey, 17-Oct-03 4:02
memberAlexey17-Oct-03 4:02 
GeneralVC60.pdb Pin
dade88888, 16-Oct-03 23:01
memberdade8888816-Oct-03 23:01 
GeneralRe: VC60.pdb Pin
Alexey, 17-Oct-03 0:36
memberAlexey17-Oct-03 0:36 
GeneralRe: VC60.pdb Pin
KarstenK, 17-Oct-03 1:18
memberKarstenK17-Oct-03 1:18 
Generaldata not updated in DBFMemCursor Pin
liyuncheng, 5-Oct-03 18:23
sussliyuncheng5-Oct-03 18:23 
GeneralRe: data not updated in DBFMemCursor Pin
liyuncheng, 5-Oct-03 18:27
sussliyuncheng5-Oct-03 18:27 
GeneralSource for other apps - DBFNavigator, NTXFiew, etc. Pin
drpc, 26-Jul-03 2:46
memberdrpc26-Jul-03 2:46 
GeneralRe: Source for other apps - DBFNavigator, NTXFiew, etc. Pin
Anonymous, 27-Jul-03 20:49
sussAnonymous27-Jul-03 20:49 
GeneralUpdating table structure of 1 file from another. Pin
Anonymous, 21-Jul-03 8:30
sussAnonymous21-Jul-03 8:30 
GeneralRe: Updating table structure of 1 file from another. Pin
Alexey, 21-Jul-03 20:15
memberAlexey21-Jul-03 20:15 
GeneralRe: Updating table structure of 1 file from another. Pin
Anonymous, 23-Jul-03 10:40
sussAnonymous23-Jul-03 10:40 
GeneralOracle Export to DBF Pin
Hamed Abnagar, 19-Jul-03 18:12
memberHamed Abnagar19-Jul-03 18:12 
QuestionHow to create a datetime field and what format is the datetime for input? Pin
liyuncheng, 17-Jul-03 17:40
memberliyuncheng17-Jul-03 17:40 
AnswerRe: How to create a datetime field and what format is the datetime for input? Pin
Alexey, 17-Jul-03 20:15
memberAlexey17-Jul-03 20:15 
QuestionHow to pack deleted record? Pin
liyuncheng, 14-Jul-03 17:21
memberliyuncheng14-Jul-03 17:21 
AnswerRe: How to pack deleted record? Pin
Alexey, 14-Jul-03 20:22
memberAlexey14-Jul-03 20:22 

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 | Terms of Use | Mobile
Web04 | 2.8.150427.2 | Last Updated 6 Nov 2002
Article Copyright 2002 by Alexey
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid