Modify DBF Structure

Modify DBF Structure

Postby Jeff Barnes » Wed Mar 28, 2018 8: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)
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Re: Modify DBF Structure

Postby Enrico Maria Giordano » Wed Mar 28, 2018 9: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
User avatar
Enrico Maria Giordano
 
Posts: 8521
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Modify DBF Structure

Postby driessen » Thu Mar 29, 2018 7: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. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
User avatar
driessen
 
Posts: 1417
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot], nageswaragunupudi and 68 guests