Forum > Database

Dbf Components Access ... [SOLVED]

<< < (2/2)

Okay, created a DataModule and moved all my Dbf table components to the DataModule form.  Removed them from all the other Forms leaving the DataSets on those forms and pointed them all to the correct Dbf's on the DataModule.  Compiled and Lazarus is having an issue with the Var declaration in the DataModule unit.
Here's the error:  datamodulepms.pas(32,1) Fatal: Syntax error, "identifier" expected but "IMPLEMENTATION" found
from these lines in the DataModule unit:

unit DataModulePMS;

{$mode ObjFPC}{$H+}


  Classes, SysUtils, dbf, DB;


  { TDataModulePMS }

  TDataModulePMS = class(TDataModule)
    DbfFirmTypes: TDbf;
    DbfSTProvCodes: TDbf;
    DbfRefTypes: TDbf;
    DbfReferences: TDbf;
    DbfCountries: TDbf;
    DbfContacts: TDbf;
    DbfClients: TDbf;
    DbfAppmts: TDbf;



  DataModulePMS: TDataModulePMS;


{$R *.lfm}


could be
unit name is same as var, try renaming the var

unit DataModulePMS;
  DataModulePMS: TDataModulePMS;

note I personally keep unit names all lowercase as some OS's are case sensative

The case in the unit name by itself does not matter (and I do prefer it to be in camel-case for better readability), but it is important that the unit is saved in lowercase name since Lazarus seeks for a unit in lowercase as fall-back if it does not find it in the exact unit name case. But Lazarus normally does this by default. So, when you save a unit as "DataModulePMS" the unit name (the word in the first line of the unit) is written exactly like this, but the file is saved as "datamodulepms".

Yes, the equality of the unit name and the variable name is the problem. Rename the unit to "uDatamodulePMS", or something similar - I usually put a project-typical prefix in front of the unit name instead of the "u" (which stands for "unit").

As for the initial question whether to have also the TDataSource components on the datamodule, I'd recommend to put them on the forms where they are needed. This is a bit unusual because many text books tell to put them on the datamodule next to the dataset components to which they are linked. But when there is any chance that you once might switch the database system, maybe from DBF to SQLite3, I think you have less work when the datasources are not in the same unit as the datasets; and you could even run both systems in parallel for some time and for easier testing.

Thanks, I agree. Moving all the Dbf's back to their appropriate forms where they are needed. I attempted to rename all names to all lower case but that didn't cure the error.


[0] Message Index

[*] Previous page

Go to full version