SIGN UP MEMBER LOGIN:    
ARTICLE

xBase Engine for C# and VB.NET

Posted by Ricardo Federico Articles | ADO.NET in C# February 25, 2002
This library is written to handle DBF files from C# or VB.NET applications.
Reader Level:
Download Files:
 

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!!!

Login to add your contents and source code to this article
share this article :
post comment
 

Hi, thanks for the code, I don't know if you always follow this thread but there is a bug with indexes, I have a database, index on one field and the application loops around without stopping ... if you want I can send you all the material necessary to reproduce the problem, just send me an email to d.hugo@skynet.be thanks in advance, sincerly, Domi

Posted by Domi Nov 15, 2011

Hola Federico, Soy profesor de la universidad de la Habana y necesito editar un .dbf. La clase que tu programaste pienso que me podría ser útil, desgraciadamente no logro descargarlo, aquí la Internet es lentísima y tengo problemas hasta para registrarme. Si pudieses mandarme el fichero a mi dirección de correo te lo agradecería un mundo: bolufé@matcom.uh.cu , gracias, Antonio Bolufé.

Posted by antonio bolufe May 19, 2009

Hello. Thank you for xBase Engine.

Actually I have question on how to utilize this library. I'm using visual studio 2008 C # for my project and I'm dealing with Dbf file from time portal software. I already downloaded xBaseEngineRFV.zip and installed it in my pc. When I tried to open db.sln the system couldn't load db.vcproj because its project type is not supportted by this version. What should I do? Thank you.

my email mabojon69@gmail.com

Posted by Mohamad Omar May 05, 2009

Hola Federico ! Estoy utilizando la clase que nos has dejado por aquí y me encontré con un problema en un archivo dbf. Aparentemente no lo abre porque tiene un campo memo. ¿ Puede ser esto ? ¿ Se puede usar la clase con archivos indices .NTX ? Si puedes ver el archivo dbf te lo mando. Muchas gracias. Carlos Pizzi carlos.pizzi@gmail.com

Posted by Carlos Pizzi Apr 24, 2009
Nevron Gauge for SharePoint
Become a Sponsor
PREMIUM SPONSORS
  • Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
    Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor