Modify DBF Structure

Post Reply
User avatar
Jeff Barnes
Posts: 912
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada
Contact:

Modify DBF Structure

Post by Jeff Barnes »

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 12.01, xHarbour 1.2.1, Bcc582)
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: Modify DBF Structure

Post by Enrico Maria Giordano »

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

EMG
User avatar
driessen
Posts: 1239
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Re: Modify DBF Structure

Post by driessen »

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. 21.01 - Harbour 3.2.0 (October 2020) - xHarbour Builder (January 2020) - Bcc7
Post Reply