tags:

views:

180

answers:

5

In Delphi for Win32, how to read and write a dbf file in a native way, without the BDE? I know there are some components available in the web, but I have never used any of them, so I don't know wich to choose (if any).

A: 

It is not hard to read a DBF file if you don't need indexes. The format is pretty straightforward. A header followed for fixed sized registers. There is a flag in each register which indicates if it is deleted or not. I suggest looking for a component which does what you want. You can find some in Torry's Delphi pages.

Eduardo Mauro
A: 

I used Topaz from Software Science for many years before I got started with Firebird. It was always an excellent library, had a terrific manual and good technical support. It supports indexes and even has an in-memory option. I think it would be a good choice.

+6  A: 

You can use ADO to access a DBF File

See ths sample code (using an TAdoConnection and TAdoDataSet components).

var
dbf_folder : string;
begin
  dbf_folder:='c:\bdd';//set your dbf folder location here 
  ADOConnection1.LoginPrompt:=false;
  ADOConnection1.ConnectionString:=Format('Provider=Microsoft.JET.OLEDB.4.0;Data Source=%s;Extended Properties=dBase IV;',[dbf_folder]);
  try
  ADOConnection1.Connected:=True;
  ADODataSet1.CommandText:='Select * from file.dbf'; //make your SQL query using the name of the dbf file
  ADODataSet1.Open;
   while not ADODataSet1.eof do
   begin
   //do your stuff here
   //ADODataSet1.FieldByName('').AsString
   ADODataSet1.Next;
   end;
  except
    on E : Exception do
      ShowMessage(E.Message);
  end;
end;
RRUZ
+1 for a "out-of-the-box" Delphi solution
Marjan Venema
This just works for my purpose
eKek0
+1  A: 

Apollo Database VCL.

rajeem_cariazo
I used this one, but migrated to TDBF, mainly because of speed reasons. Despite having bought Apollo
Marco van de Voort
+6  A: 

I used TDBF back when I was still working with DBF files (some legacy apps). I still use it for maintainance of those apps here and there. It is free, has a lot of features and works good.

Runner