Forum > Database
Dbf Components Access ... [SOLVED]
1HuntnMan:
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+}
interface
uses
Classes, SysUtils, dbf, DB;
type
{ TDataModulePMS }
TDataModulePMS = class(TDataModule)
DbfFirmTypes: TDbf;
DbfSTProvCodes: TDbf;
DbfRefTypes: TDbf;
DbfReferences: TDbf;
DbfCountries: TDbf;
DbfContacts: TDbf;
DbfClients: TDbf;
DbfAppmts: TDbf;
private
public
end;
var
DataModulePMS: TDataModulePMS;
implementation
{$R *.lfm}
end.
Josh:
could be
unit name is same as var, try renaming the var
unit DataModulePMS;
var
DataModulePMS: TDataModulePMS;
note I personally keep unit names all lowercase as some OS's are case sensative
wp:
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.
1HuntnMan:
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.
PROBLEM SOLVED!
Navigation
[0] Message Index
[*] Previous page