xBase Engine for C# and VB.NET

Overview

I've removed the dust to some code that Ive used a while ago for access FoxPro database files (DBFs and Idxs) from C++, in a manner compatible with FoxPro 2.6.

To use DBF files in .NET, I have written a wrapper that allows you to access DBFs directly from C# or VB.NET without using ODBC or ADO.NET.

This library only handles DBFs and normal Idxs. Unfortunately, it doesn't handler memos or Cdxs or compact Idxs.

The library handles shared access over the network using locking and unlocking mechanism. Some other features of the library are database table creation, cursor creation, index creation or recreation and so on. 

To use this library, you can unzip attached xBaseEngineRFV.zip into a working directory, open db solution under Visual Studio and Build Solution. This solution includes 2 projects:

  1. The engine DLL project, that make db.dll that you can add to any C# or VB.NET project.
  2. A test program written in C#. This program uses some of the functionality of the engine. 

Description

It is complicated to build a DBF engine without the services of expression evaluator, internal functions, memory variable manager and so on. But this engine gives you all tools that you would need for utilizing DBF files on the network. 

The best way to learn and use the engine is look at the example code that ships with this solution. In resume, you cant:

  1. Construct one or more objects based on xdbf class. At this time, the object not represent any database, is only a container.
  2. Open a database. You can open an existing dbf (utilizing .Use() method), or create a new one (using CreaTable() or CreaCursor() methods).
  3. If you need, attach existing indexes (using SetIndex() methods) or create new ones (using IndexOn() methods).
  4. Manipulate databases. You can add new records (using AppendBlank() method), get field data (using Get() method) or replace data (using Replace() method). You can test for end of file condition (using Eof property) or begin of file condition (using Bof property). You can delete records (using Delete() method), or know the count of records (using RecCount property) or the deleted status of a record (using Delete property).
  5. Navigate through database, utilizing sequential search (using Locate() method), indexed search (using SetOrder() and/or Seek() methods), absolute positioning (using Go() method) or relative positioning (using Skip() method).
  6. If you are utilizing shared databases, you can lock or unlock records (using Lock() method). Engine perform automatic locking before replace, with auto refresh of record information.
  7. You can set relations between open databases (using SetRelation()).
  8. Close databases. The close is performed automatically when the container object is destroyed. 

There are more methods and properties available. Some of the methods you can use to utilize to request fields types, fields sizes and so on. Try it!!!


Similar Articles