Recent

Author Topic: [SOLVED] Tdbf FPC components vs Lazarus DataAcess TDbf???  (Read 1724 times)

1HuntnMan

  • Sr. Member
  • ****
  • Posts: 276
  • From Delphi 7 to Lazarus
    • NewFound Photo Art
[SOLVED] Tdbf FPC components vs Lazarus DataAcess TDbf???
« on: February 10, 2024, 09:03:41 pm »
When first I installed Lazarus a few months ago and just starting programming after a long, long time ago with Delphi 7, I started creating my first app using Dbf tables/indexes included with Lazarus. The different components I guess you would call them at the top of the work area or IDE you can click on the Data Access and click on the DBF component and place it on a form. And then use other Data Controls, etc.
I understand this has bugs or does it. Here's a comment awhile back from IRET, "DBase is really outdated and the TDbf FPC components have major bugs concerning index files. If you really want to use dbase files you should use the original TDbf from sourceforge."
So, what is IRET referring to, the DBF component that comes with Lazarus in the Data Access?
The original TDbf from SourceForge is different, correct?
« Last Edit: February 14, 2024, 04:28:42 pm by 1HuntnMan »

1HuntnMan

  • Sr. Member
  • ****
  • Posts: 276
  • From Delphi 7 to Lazarus
    • NewFound Photo Art
Re: Tdbf FPC components vs Lazarus DataAcess TDbf???
« Reply #1 on: February 10, 2024, 09:16:03 pm »
Should I install this from SourceForge? https://sourceforge.net/projects/dzpackageinst/ (titled:
dzpackageinst -> a package installer for Delphi 6 to 10.3)
OR this:  [ Titled: https://sourceforge.net/projects/tdbf/ -> tDBF component for Delphi and BCB
TDBF is a native dBASE III+, dBase IV and dBase 2k data access component for Delphi, BCB, Kylix, FreePascal. It allows you to create very compact database programs which don't need any special installer programs. The DB engine code is compiled right into your executable. ]


wp

  • Hero Member
  • *****
  • Posts: 12459
Re: Tdbf FPC components vs Lazarus DataAcess TDbf???
« Reply #2 on: February 10, 2024, 10:55:10 pm »
You should use the "Download" button in https://sourceforge.net/projects/tdbf/ to get a zip of the dbf component, unzip it and install the .lpk files in the packages/Lazarus folder of the unzipped package.

Do not use any third-party installers.

BUT: I tried it, and was not able to install it because the lpk files are broken, they do not contain the correct path to the units. But even after fixing this in my local copy the IDE could not be rebuilt. This is really not normal. I try to report a bug on sourceforge.

If you urgently need this package I think you can only use it at runtime (this is what is done in MyDBFStudio), i.e. you must create the TDbf component and set its properties in code - not a big deal, but many users want to have it on the component palette. Tell me if you want to do it this way, then I'll tell you how to fix the runtime package.

1HuntnMan

  • Sr. Member
  • ****
  • Posts: 276
  • From Delphi 7 to Lazarus
    • NewFound Photo Art
Re: Tdbf FPC components vs Lazarus DataAcess TDbf???
« Reply #3 on: February 11, 2024, 10:22:13 pm »
Okay WP, but am I correct that when I installed Lazarus back in Nov. 2023, I've since kept up with the upgrades and have the latest version installed, the components in the IDE under the Data Access: TDbf and TDataSource are an issue????
If so, then eventually may want to install the SourceForge TDbf version. I'm just testing and relearning how to design.  No issues except that the second system I'm designing for a fellow photographer is a Photographer's Mgt. System. TRon educated me on the Jvcl components which make it easy to design index selection with  a TComboBox but context searching via TJvDBSearchEdit. This works nifty in the Clients and Contacts forms but I mistyped and mixed up the Index Name with the field name designing the Appointments form. What happened in the TDbf index file (.mdx) indexes were just appearing on the fly which I didn't create.  I figured out my typos but my first thought was that there was a bug in the TDbf/mdx or something. So, started searching if that was so. Anyway, not a big deal. My first little project was a super-duper Contacts Mgt. system I designed with Laz just to get back into the groove after not programming in a long time. I'm retired and doing this because I love it. Anyway a bunch of my friends that are photographer's are really liking the Contacts app because Winders doesn't come with a Contacts app like Apple iPhones, iPads, etc. Now, they want me to design a Photographer's Mgt. System so I'm thinking even though this isn't a multi-user system or maybe at the most 4-5 users,  to ditch dbase and use SQLite.
Back in the olden days when I migrated from Turbo Pascal and started programming with Delphi 5 then 7 I used Paradox database. (*.DB files) Paradox doesn't seem to be supported anymore so relearning with dbase.

wp

  • Hero Member
  • *****
  • Posts: 12459
Re: Tdbf FPC components vs Lazarus DataAcess TDbf???
« Reply #4 on: February 11, 2024, 11:44:01 pm »
The TDbf which is installed in Lazarus by default on the "Data Access" palette, is good for most of the work. However, when I took over MyDbfStudio for some renovation, I noticed that there is an issue with indexes, I cannot remember any details. I took the easy way and switched over to the TDbf on Sourceforge which resolved the issue, similarly as I had read from others here.

I am sure that the index issues of the TDbf version can be fixed. What is missing is a clear bug report describing the issue and the way how to reproduce it.

The other version of TDbf on Sourceforge currently is broken and cannot be installed. I filed a bug report yesterday, maybe it gets fixed. Nevertheless, it can be used in runtime code (like in MyDbfStudio), however, after a tiny modification.

As for Paradox files: You can read them by means of the TParadoxDataset package which can be installed from Online-Package-Manager. You cannot use it to write to Paradox files, though. There is another paradox package even in the Lazarus source tree installation which can read and write. However, it needs external dlls, is Windows-only and usable only for 32-bit (IIRC).

1HuntnMan

  • Sr. Member
  • ****
  • Posts: 276
  • From Delphi 7 to Lazarus
    • NewFound Photo Art
Re: Tdbf FPC components vs Lazarus DataAcess TDbf???
« Reply #5 on: February 12, 2024, 03:50:15 pm »
This is what I messed up yesterday that was causing the procedure (CmboBxSelectIndexExit) below to create indexes on the fly...
var
  FrmAppmts: TFrmAppmts;
  keys: TStringList;
 
procedure TFrmAppmts.CmboBxSelectIndexSelect(Sender: TObject);
begin
  case CmboBxSelectIndex.Text of
    'Contact (L,F,M)':DbfAppmts.IndexName:= 'CNTKNAME';
    'Client/Customer':DbfAppmts.IndexName:= 'CLIENT';
    'Appt. Date/Time':DbfAppmts.IndexName:= 'APPTDTIME'
  else
    WriteLn ('Index Unchanged!');
  end;
  JvDBSrchByIndex.DataField:= '';
  DbfAppmts.Refresh;
end;

procedure TFrmAppmts.CmboBxSelectIndexExit(Sender: TObject);
var
  I: Integer;
begin
  keys:= TStringList.Create;
  keys.Delimiter:= ':';
  keys.NameValueSeparator:= '=';
  keys.StrictDelimiter:= True;
  keys.DelimitedText:= 'Contact (L,F.M)=CNTKLNAME:Client/Customer=CLIENT:'+
   'Appt. Date/Time=APPTDATETIME';
  I:= keys.IndexOfName(CmboBxSelectIndex.Text);
  if I <> -1 then JvDBSrchByIndex.DataField:= keys.ValueFromIndex;
  DbfAppmts.Refresh;
end;

What I figured out testing is, I must of been in Dementia mode because in  the CmboBxSelectIndexExit I had assigned the index names instead of the field names. I corrected that this morning but these 2 procedures won't work if you define a primary index and fieldname. Also, I removed searching by the primary index on 3 of the units because they just didn't work properly. After compiling it's like I didn't compile anything. Nothing's changed. So, I think I'm going to wipe out Laz and reinstall everything.  There's more to this story I think! For example after removing the Primary Index from above it's rendering the CNTKNAME, CLIENT and APPTID indexes which isn't even in the code.

After I reinstall Laz, I'll let you know if things are behaving properly.

cdbc

  • Hero Member
  • *****
  • Posts: 1655
    • http://www.cdbc.dk
Re: Tdbf FPC components vs Lazarus DataAcess TDbf???
« Reply #6 on: February 12, 2024, 04:00:26 pm »
Hi
Under your project-dir, there's a dir named lib.
Under lib there's another dir ...\win64\ I think...
In there all you project's compiled units' ppu,o,or files reside, try to delete them before you do a new install...
And recompile project of course...
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 2.2.6 up until Jan 2024 from then on it's: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 3.0

wp

  • Hero Member
  • *****
  • Posts: 12459
Re: Tdbf FPC components vs Lazarus DataAcess TDbf???
« Reply #7 on: February 12, 2024, 04:12:24 pm »
Code: Pascal  [Select][+][-]
  1. procedure TFrmAppmts.CmboBxSelectIndexSelect(Sender: TObject);
  2. begin
  3.   case CmboBxSelectIndex.Text of
  4.     'Contact (L,F,M)':DbfAppmts.IndexName:= 'CNTKNAME';
  5.     'Client/Customer':DbfAppmts.IndexName:= 'CLIENT';
  6.     'Appt. Date/Time':DbfAppmts.IndexName:= 'APPTDTIME'
  7.     [...]
  8.   end;
  9. [...]
  10. end;
  11.  
  12. procedure TFrmAppmts.CmboBxSelectIndexExit(Sender: TObject);
  13.  
  14. begin
  15.   [...]
  16.   keys.DelimitedText:= 'Contact (L,F.M)=CNTKLNAME:Client/Customer=CLIENT:'+
  17.   [...]
  18. end;
  19.  
At first: please put your code into [ code ] tags - this makes it easier for us to read your code, and it avoids that the forum software interprets indices [ i] as instruction to render the following text in italic.

Then: Is this a typo in 'Contact(L,F.M)' (line 16), using a point rather than a comma as in the first occurance (line 4)?
« Last Edit: February 12, 2024, 04:27:26 pm by wp »

1HuntnMan

  • Sr. Member
  • ****
  • Posts: 276
  • From Delphi 7 to Lazarus
    • NewFound Photo Art
Re: Tdbf FPC components vs Lazarus DataAcess TDbf???
« Reply #8 on: February 12, 2024, 04:35:57 pm »
Is this what you mean by putting code in as tags or encapsulated within
Code: Pascal  [Select][+][-]
  1.  my code
?

Code: Pascal  [Select][+][-]
  1. procedure TFrmAppmts.CmboBxSelectIndexSelect(Sender: TObject);
  2. begin
  3.   case CmboBxSelectIndex.Text of
  4.     'Contact (L,F,M)':DbfAppmts.IndexName:= 'CNTKNAME';
  5.     'Client/Customer':DbfAppmts.IndexName:= 'CLIENT';
  6.     'Appt. Date/Time':DbfAppmts.IndexName:= 'APPTDTIME'
  7.   else
  8.     WriteLn ('Index Unchanged!');
  9.   end;
  10.   JvDBSrchByIndex.DataField:= '';
  11.   DbfAppmts.Refresh;
  12. end;
  13.  
  14. procedure TFrmAppmts.CmboBxSelectIndexExit(Sender: TObject);
  15. var
  16.   I: Integer;
  17. begin
  18.   keys:= TStringList.Create;
  19.   keys.Delimiter:= ':';
  20.   keys.NameValueSeparator:= '=';
  21.   keys.StrictDelimiter:= True;
  22.   keys.DelimitedText:= 'Contact (L,F.M)=CNTKLNAME:Client/Customer=CLIENT:'+
  23.    'Appt. Date/Time=APPTDATETIME';
  24.   I:= keys.IndexOfName(CmboBxSelectIndex.Text);
  25.   if I <> -1 then JvDBSrchByIndex.DataField:= keys.ValueFromIndex[I];
  26.   DbfAppmts.Refresh;
  27. end;
  28.  

Also, didn't understand...  Is this a typo in 'Contact(L,F.M)' (using a point rather than a comma as in the first occurrence)? What's a point? In the first procedure I'm just defining what the user sees as the index.   'Contact (L,F,M)':DbfAppmts.IndexName:= 'CNTKNAME'; The drop-down shows them sort by Contact (L,F,M) or by Client/Customer, etc. Then, in the JvDBSrchByIndex.DataField component which is the second procedure the user is typing and it's suppose to be context-sensitive search by what's being typed into the component.

I'm going to delete everything under C:\Users\DKing\Documents\Software Development\PMS Project\lib\x86_64-win64 and then recompile and see if that changes something ... Tks

1HuntnMan

  • Sr. Member
  • ****
  • Posts: 276
  • From Delphi 7 to Lazarus
    • NewFound Photo Art
Re: Tdbf FPC components vs Lazarus DataAcess TDbf???
« Reply #9 on: February 12, 2024, 04:38:23 pm »
Woops, you're right just saw it, it's a typeo. Should be a comma.

wp

  • Hero Member
  • *****
  • Posts: 12459
Re: Tdbf FPC components vs Lazarus DataAcess TDbf???
« Reply #10 on: February 12, 2024, 04:45:18 pm »
Woops, you're right just saw it, it's a typeo. Should be a comma.
Does it solve your issue?

1HuntnMan

  • Sr. Member
  • ****
  • Posts: 276
  • From Delphi 7 to Lazarus
    • NewFound Photo Art
Re: Tdbf FPC components vs Lazarus DataAcess TDbf???
« Reply #11 on: February 12, 2024, 05:03:11 pm »
No, didn't solve the issue. Screenshot of the CmboBxSerchBy but the drop-down is displaying:  Name (L,F,M)
Client/Customer
Appt. No.

BUT, that's not the way it's coded, it's displaying what I had coded yesterday.  The current code is:

Name (L,F,M)
Client/Customer
Appt. Date/Time




 

wp

  • Hero Member
  • *****
  • Posts: 12459
Re: Tdbf FPC components vs Lazarus DataAcess TDbf???
« Reply #12 on: February 12, 2024, 06:16:46 pm »
Can't help you because I don't know the details of your project.

Just wanted to verifiy that indexes can be changed with the TDbf component in the Lazarus distribution. Yes - at least the code in the attached project is working which is modified from https://wiki.freepascal.org/Example:_TDbf_(creating_table_and_indexes,_selecting_of_index), even with a combined index.

1HuntnMan

  • Sr. Member
  • ****
  • Posts: 276
  • From Delphi 7 to Lazarus
    • NewFound Photo Art
Re: Tdbf FPC components vs Lazarus DataAcess TDbf???
« Reply #13 on: February 14, 2024, 12:16:53 am »
WP, you are my hero member, Ha!
Anyway, I wish I had read this post before I reinstalled Lazarus.  I opened up your sample unit about 30 minutes and started looking thru your unit1 code for your ComboBx and it hit me right in the face.  One line a code, Combobox1.Items.Clear!
I was concentrating so hard on the why my ComboBox items were not showing what I had changed in my comboboxselect procedure. When I first added the ComboBoxSelect component to the form a few weeks ago, I had typed in the items Strings in the ComboBox-Properties Items but forgot about when I was changing the way context sensitive search and even add another index but didn't update the Property-Items. I hard coded like you showed me in the Unit combobx example where you cleared the items before doing anything. LoL! That was all it was. Thanks my friend! Take Care...

 

TinyPortal © 2005-2018