Hello Stoutall,
Welcome to the forum.
You don't need to use MS. Access driver nor ODBC to connect dbf files. But you first need to make sure your Lazarus already has DBFLaz package installed properly:
Lazarus main menu > Package > Install/Uninstall Packages
If you can see
DBFLaz 0.1.1 on the left panel, then it means it's already installed. If it is on the
right panel, you should double click on it and click "
Save and rebuild IDE", wait some minutes then your IDE will be restarted.
Here I wrote a simple demo to show how to connect dbf file and show its fields' names:
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, dbf, FileUtil, Forms, Controls, Graphics, Dialogs,
StdCtrls;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
Dbf1: TDbf;
OpenDialog1: TOpenDialog;
procedure Button1Click(Sender: TObject);
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.Button1Click(Sender: TObject);
var
S: string;
i: Integer;
begin
if not(OpenDialog1.Execute) then Exit;
S := 'Field Names:';
try
with Dbf1 do
begin
FilePathFull := ExtractFileDir(OpenDialog1.FileName);
TableName := ExtractFileName(OpenDialog1.FileName);
Open;
for i := 0 to (FieldDefs.Count-1) do
S := S + #13 + FieldDefs[i].Name;
Close;
end;
except
S := 'Error!'
end;
ShowMessage(S);
end;
end.
You can download the DBFields.zip for testing.