FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Modify DBF Structure
Posts: 933
Joined: Sun Oct 09, 2005 01:05 PM
Modify DBF Structure
Posted: Wed Mar 28, 2018 08:08 PM

Is there a way via code to adjust the field size in a DBF file ?

I have a numeric field that is currently 4 chars in size.
I would like to be able to use code to change it to a size of 6 (no decimals)

Thanks,

Jeff Barnes



(FWH 16.11, xHarbour 1.2.3, Bcc730)
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Modify DBF Structure
Posted: Wed Mar 28, 2018 09:07 PM

As far as I know, you have to create a new DBF structure and copy the old data to the new DBF.

EMG

Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM
Re: Modify DBF Structure
Posted: Thu Mar 29, 2018 07:40 AM

Jeff, this is the way I change DBF structures while upgrading my application.

I have a folder called DATA, containing all the DBF-files with the data of my application.
I have a second folder, called DATABESC, containing the same DBF-files, but only containing 1 record.

While upgrading, in de folder DATA, I take the first DBF-file (let's call it FILE1.DBF), rename it to FILE1OLD.DBF.
Then I make a new FILE1.DBF, using the structure of FILE1.DBF in the folder DATABESC.
Then I copy all the records from FIL1OLD.DBF to FILE1.DBF.
If a field is added, I give the field in my records the same value as it has in FIL1.DBF in de DATABESC-folder.
After having copied all the records to FILE1.DBF, this file has been changed to the new DBF-structure.
Finally, FILE1OLD.DBF is deleted.

So, if I need to change the DBF-structure, I change it in the DBF-file in the DATABESC-folder after which my upgrade-program is run.

I hope I was able to make myself clear.

Good luck.

Regards,

Michel D.
Genk (Belgium)


_____________________________________________________________________________________________

I use : FiveWin for (x)Harbour v. 25.12 - Harbour 3.2.0 (May 2025) - xHarbour Builder (January 2020) - Bcc773

Continue the discussion