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

The alxBase classes for work with DBF files

By , 5 Nov 2002
 

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

About the Author

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

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
Hint: For improved responsiveness ensure Javascript is enabled and choose 'Normal' from the Layout dropdown and hit 'Update'.
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralUsing the FindFirst functionmemberAlex Evans1 Nov '04 - 11:14 
GeneralRe: Using the FindFirst functionmemberEndlessWinter10 Feb '05 - 16:23 
GeneralConverted library for Windos CEmemberAlex Evans2 Oct '04 - 21:53 
GeneralUsing this with Windows CEmemberAlex Evans1 Oct '04 - 20:51 
GenerallockRecord()memberthangoftin29 Aug '04 - 18:18 
GeneralUsing the FindFirst functionmemberAlex Evans1 Nov '04 - 11:17 
QuestionHow can i insert/update/delete image file?memberMr.Ahn7 Jul '04 - 1:21 
QuestionHow to pack deleted recordmembersimranjeet11 Jun '04 - 3:08 
AnswerRe: How to pack deleted recordmemberAlexey14 Jun '04 - 19:28 
QuestionHow to pack deleted recordsusssimranjit11 Jun '04 - 3:02 
QuestionSample db files?memberchenhuisheng13 Apr '04 - 15:21 
GeneralGreat!! - one questionmemberbdiamond29 Mar '04 - 3:30 
GeneralRe: Great!! - one questionmemberAlexey29 Mar '04 - 18:33 
Generalcan't write header info correctlymemberbdiamond18 Mar '04 - 7:10 
GeneralRe: can't write header info correctlymemberAlexey18 Mar '04 - 19:42 
Generale:\temp\alxBASE\SRC\ALXParserFuncDef.cpp(1221): error C2666: &#8220;pow&#8221; : 7 overloads have the similar conversionmemberTom_lyd17 Dec '03 - 20:10 
GeneralRe: e:\temp\alxBASE\SRC\ALXParserFuncDef.cpp(1221): error C2666: ?pow? : 7 overloads have the similar conversionmemberDmitry Naumov21 Jan '04 - 21:14 
GeneralRe: e:\temp\alxBASE\SRC\ALXParserFuncDef.cpp(1221): error C2666: ?pow? : 7 overloads have the similar conversionmemberm0xx22 Jun '04 - 21:57 
GeneralRe: e:\temp\alxBASE\SRC\ALXParserFuncDef.cpp(1221): error C2666: ?pow? : 7 overloads have the similar conversionmembershaunwerkhoven28 Sep '04 - 0:15 
GeneralRe: e:\temp\alxBASE\SRC\ALXParserFuncDef.cpp(1221): error C2666: ?pow? : 7 overloads have the similar conversionsussGanjoo11 Oct '04 - 4:00 
GeneralRe: e:\temp\alxBASE\SRC\ALXParserFuncDef.cpp(1221): error C2666: ?pow? : 7 overloads have the similar conversionmemberAnthony_Yio17 May '05 - 23:11 
GeneralHelp, I'm a newbiememberarktow6 Nov '03 - 8:06 
GeneralRe: Help, I'm a newbiememberAlexey9 Nov '03 - 19:53 
GeneralAssertion Failed!memberdade8888817 Oct '03 - 0:20 
GeneralRe: Assertion Failed!memberAlexey17 Oct '03 - 3:02 
GeneralVC60.pdbmemberdade8888816 Oct '03 - 22:01 
GeneralRe: VC60.pdbmemberAlexey16 Oct '03 - 23:36 
GeneralRe: VC60.pdbmemberKarstenK17 Oct '03 - 0:18 
Generaldata not updated in DBFMemCursorsussliyuncheng5 Oct '03 - 17:23 
GeneralRe: data not updated in DBFMemCursorsussliyuncheng5 Oct '03 - 17:27 
GeneralSource for other apps - DBFNavigator, NTXFiew, etc.memberdrpc26 Jul '03 - 1:46 
GeneralRe: Source for other apps - DBFNavigator, NTXFiew, etc.sussAnonymous27 Jul '03 - 19:49 
GeneralUpdating table structure of 1 file from another.sussAnonymous21 Jul '03 - 7:30 
GeneralRe: Updating table structure of 1 file from another.memberAlexey21 Jul '03 - 19:15 
GeneralRe: Updating table structure of 1 file from another.sussAnonymous23 Jul '03 - 9:40 
GeneralOracle Export to DBFmemberHamed Abnagar19 Jul '03 - 17:12 
QuestionHow to create a datetime field and what format is the datetime for input?memberliyuncheng17 Jul '03 - 16:40 
AnswerRe: How to create a datetime field and what format is the datetime for input?memberAlexey17 Jul '03 - 19:15 
QuestionHow to pack deleted record?memberliyuncheng14 Jul '03 - 16:21 
AnswerRe: How to pack deleted record?memberAlexey14 Jul '03 - 19:22 
Generalsort a dbfmemberbtorrey10 Jun '03 - 13:18 
GeneralRe: sort a dbfmemberbtorrey10 Jun '03 - 16:31 
QuestionHow to add Memo filed?memberJerry Chen(SDCC)26 May '03 - 16:52 
AnswerRe: How to add Memo filed?memberAlexey26 May '03 - 20:56 
GeneralRe: How to add Memo filed?memberJerry Chen(SDCC)26 May '03 - 23:29 
GeneralRe: How to add Memo filed?memberAlexey27 May '03 - 0:39 
GeneralRe: How to add Memo filed?memberJerry Chen(SDCC)27 May '03 - 15:27 
GeneralRe: How to add Memo filed?memberJerry Chen(SDCC)27 May '03 - 17:31 
GeneralUpdating .cdx filesmembergisraelsson22 May '03 - 4:04 
GeneralRe: Updating .cdx filesmemberAlexey22 May '03 - 19:59 

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

Permalink | Advertise | Privacy | Mobile
Web01 | 2.6.130516.1 | Last Updated 6 Nov 2002
Article Copyright 2002 by Alexey
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid