View Issue Details

IDProjectCategoryView StatusLast Update
0019961FPCDatabasepublic2011-10-15 17:03
ReporterGary Dale Assigned ToJonas Maebe  
Status resolvedResolutionsuspended 
Summary0019961: Can't write to .dbf files under Linux
DescriptionUsing the same source code and files, I've found that I can't write (insert, edit) dBASE records under Linux but I have no trouble doing it with the program running under Wine. The program reports a read-only error when I attempt to execute a database.insert or database.edit command.

The attached file demonstrates the problem. Use LibreOfice Calc (or similar) to create two .DBF files (call the second one WARDS2.DBF) with at least three text fields. Add some data to one (but leave WARDS2.DBF empty). Then run the program.
TagsNo tags attached.
Fixed in Revision
Attached Files


2011-08-11 17:11


unit1.pas (2,911 bytes)   
unit Unit1; 

{$mode objfpc}{$H+}


  Classes, Dbf, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, Menus,


  { TMainForm }

  TMainForm = class(TForm)
    FileMenu: TMainMenu;
    ImportMenuItem: TMenuItem;
    FileMenuItem: TMenuItem;
    OpenDialog1: TOpenDialog;
    ProgressBar1: TProgressBar;
    procedure ImportMenuItemClick(Sender: TObject);
    { private declarations }
    { public declarations }

  MainForm: TMainForm;


{$R *.lfm}

{ TMainForm }

procedure TMainForm.ImportMenuItemClick(Sender: TObject);
  var FullFileName, PathPart, NamePart: String;
      wardstable, toTable: TDbf;

  Procedure SplitFileName(var FullName, FullPath, TableName: String);
     var SplitPos: Integer;
         SplitPos := LastDelimiter('/\', FullName);
         FullPath := Copy(FullName, 1, SplitPos);
         TableName := Copy(FullName, SplitPos + 1, Length(FullName) - SplitPos)

  Procedure ShowTableFields(var ShowTable: TDbf);
     var CurField: String;
         i: Cardinal;
         Str(ShowTable.FieldCount, CurField);
         ShowMessage(ShowTable.TableName + ' contains ' + CurField + ' fields.');
         for i := 0 to ShowTable.FieldCount - 1 do begin
           CurField := ShowTable.Fields[i].FieldName;
           ShowMessage('Field: ' + CurField)

  Procedure ImportData(var fromTable, toTable: TDbf);
     var i: Cardinal;
         curRec: String;
         fromTable.ReadOnly := True;
         Str(fromTable.RecordCount, CurRec);
         ShowMessage('importing ' + CurRec + ' records');
         ProgressBar1.Max      := fromTable.RecordCount;
         ProgressBar1.Position := 0;
         ProgressBar1.Visible  := True;
         while not fromTable.EOF do begin
             ProgressBar1.Position := fromTable.recNo;
             for i := 0 to 3 do
                toTable.Fields[0].AsString := fromTable.Fields[0].Text;
         ShowMessage('Finished importing');
         ProgressBar1.Visible := False;

     wardstable := TDbf.Create(nil);
     toTable := TDbf.Create(nil);
     MainForm.OpenDialog1.Title := 'Select postal code / riding file to import';
     MainForm.OpenDialog1.FilterIndex := 2;
     if MainForm.OpenDialog1.Execute then begin
        FullFileName := MainForm.OpenDialog1.FileName;
        SplitFileName(FullFileName, PathPart, NamePart);
        wardstable.FilePathFull := PathPart;
        wardstable.TableName := NamePart;
        toTable.FilePathFull := PathPart;
        toTable.TableName := 'WARDS2.DBF';
        ImportData(wardstable, toTable);



unit1.pas (2,911 bytes)   

Vincent Snijders

2011-10-14 18:48

manager   ~0052980

Last edited: 2011-10-14 18:51

Moved to fpc project, because TDbf is part of the fpc packages.

Jonas Maebe

2011-10-15 11:43

manager   ~0052989

I believe tdbf has been abandoned by its maintainer (at least none of its reported bugs have been fixed over the last couple of years afaik). Maybe it should be removed from the packages (or marked deprecated), since it's evident that people expect us to support/fix the packages we ship.

Reinier Olislagers

2011-10-15 12:33

developer   ~0052991

I'd mark it deprecated at most, with a note that the original author hasn't maintained it for years; patches welcome. Some people (like me ;) ) like that is' in a base install, and works, and don't expect fixes for everything.
Who knows, maybe somebody will come up with a patch (busy myself ATM though, and possibly to newb).

The alternative would in practice be about the same: people would need to get external code that is not supported either.
And they might start moaning (who knows) about there not being DBF support included out of the box...

Jonas Maebe

2011-10-15 12:45

manager   ~0052993

Yes, some people would definitely complain about it no longer being included. I agree that, definitely as a start, marking it as deprecated is probably the better option. And indeed, the custom deprecation message could at the same time explain why this is the case.

Marco van de Voort

2011-10-15 13:09

manager   ~0052994

I asked Micha a few days back, and he doesn't plan on maintaining tdbf anymore (either in FPC or the delphi platform).

However I think killing off tdbf is premature. It would be more logical to change tdbf from being FPC internal package to upstream, and direct them to the tdbf site on

That way these reports and their information are available to somebody who might step up maintaining the package in the future.

Jonas Maebe

2011-10-15 13:16

manager   ~0052997

I don't understand the difference between
* removing it from FPC packages, and
* change tdbf from being FPC internal package to upstream, and direct them to the tdbf site on

Or are you referring to the deprecation message with the "direct them to the tdbf site on"?

Marco van de Voort

2011-10-15 13:27

manager   ~0053000

I mean leave the sources as is, but stop accepting bugreports for them (close them with a reference to

And of course add a notice of this policy to the sources (in a readme in the tdbf source dir or so, or even the global fcl-db one)

Jonas Maebe

2011-10-15 14:22

manager   ~0053002

Since we don't install the sources when installing FPC, I think a warning on use is quite useful to have (and even if we did install the sources, I don't think it would be appropriate to expect people to check all readme's in the source tree to determine whether or not we actually support the code we are shipping).

Jonas Maebe

2011-10-15 17:03

manager   ~0053009

TDBF has been abandoned by its maintainer and is no longer supported by the FPC team (the unit is still available, but with a deprecation warning explaining the situation).

You may be able to get further help from other users on the tdbf forum at

Issue History

Date Modified Username Field Change
2011-08-11 17:11 Gary Dale New Issue
2011-08-11 17:11 Gary Dale File Added: unit1.pas
2011-10-14 18:48 Vincent Snijders Note Added: 0052980
2011-10-14 18:51 Vincent Snijders Note Edited: 0052980
2011-10-14 18:51 Vincent Snijders Project Lazarus CCR => FPC
2011-10-15 11:39 Jonas Maebe FPCOldBugId => 0
2011-10-15 11:39 Jonas Maebe Category Database => Database Components
2011-10-15 11:43 Jonas Maebe Note Added: 0052989
2011-10-15 12:33 Reinier Olislagers Note Added: 0052991
2011-10-15 12:45 Jonas Maebe Note Added: 0052993
2011-10-15 13:09 Marco van de Voort Note Added: 0052994
2011-10-15 13:16 Jonas Maebe Note Added: 0052997
2011-10-15 13:27 Marco van de Voort Note Added: 0053000
2011-10-15 14:22 Jonas Maebe Note Added: 0053002
2011-10-15 17:03 Jonas Maebe Status new => resolved
2011-10-15 17:03 Jonas Maebe Resolution open => suspended
2011-10-15 17:03 Jonas Maebe Assigned To => Jonas Maebe
2011-10-15 17:03 Jonas Maebe Note Added: 0053009