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).
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.
Double click on the file name. The . dbf file will now open in Excel.
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.
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.
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;
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With