Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to read and write dbf in a native way?

Tags:

native

delphi

dbf

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 which to choose (if any).

like image 503
eKek0 Avatar asked Sep 25 '10 23:09

eKek0


People also ask

How do you read a DBF?

To open a DBF file, go to the File menu and click the Open command or use shortcut Ctrl-O, or click the corresponding icon on the toolbar. In the file opening dialog box select the file(s), use Ctrl and Shift keys for multiple selection.

What program reads DBF files?

Double click on the file name. The . dbf file will now open in Excel.

How do I read a DBF file in Python?

How to read it using python ? “dbfread” is the library available in python to read dbf files. This library reads DBF files and returns the data as native Python data types for further processing. dbfread requires python 3.2 or 2.7.

How do I read a DBF file in Excel?

Double-click the file to open it, or select it with a single click and click the “Open” button. Excel opens the file and automatically formats the dBase fields into separate spreadsheet columns with headings created from the dBase field names.


3 Answers

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;
like image 199
RRUZ Avatar answered Oct 21 '22 18:10

RRUZ


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.

like image 41
Runner Avatar answered Oct 21 '22 16:10

Runner


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.

like image 24
jrodenhi Avatar answered Oct 21 '22 17:10

jrodenhi