Solved

Alter dBase IV table w/data loaded

Posted on 2000-04-20
8
450 Views
Last Modified: 2013-12-20
I need to add a field to a dBase IV table that is already loaded with data.  I know the table structure can not be changed once the data is loaded, so I need a way to quickly transfer the data to a new table definition.  I have tried doing this the hard, ugly way - creating a new dBase file and copying over the data field by field and record by record.  It worked, but it is way too slow.  There must be a better way.

Is it possible to convert the .dbf file to another format (such as .mdb), then add and populate a new field, and finally convert the table back to a .dbf file?  Is there a better/faster way?
0
Comment
Question by:anasazi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 1

Expert Comment

by:MT_MU
ID: 2736812
Since you have dBase IV....

Use <original_database>
Copy Struct Exte to Tmp.Dbf
Create <new_database> from Tmp.Dbf
Import From <original_database>


Then use Modi Struct to add the new fields you require.


0
 
LVL 1

Expert Comment

by:MT_MU
ID: 2736816
One correction....

instead of

Import from <original_database>

it should be

Append from <original_database>
0
 

Author Comment

by:anasazi
ID: 2738385
I don't actually have dBase IV - I'm just working with files that are in that format. Everything must be done within VB 6.0.
0
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
LVL 1

Expert Comment

by:MT_MU
ID: 2744066
Fair enough...since I attempted once - guess I should try again...

How about using a SQL Execute?

dbs.Execute "INSERT INTO newdb (field1, field2...) SELETE (field1,field2...) FROM olddb"

Concievably (if you are doing this repeatly) - you could generate the field names programaticaly.






0
 
LVL 9

Expert Comment

by:cymbolic
ID: 2744980
If you are interested, I have a utility I built for modifying DBF files. Its a small, fast utility that runs in DOS.

Unfortunately, the only way you CAN add a field to these files is by copying over the dbf file.  Format for these .dbf files incorporates the format as a header portion in each record, including the actual physical record size.  If you change that size by adding a field, you must create a new header, and copy over each record to the new .dbf with the new record size.  There is not other "Magic" way to do it, since they are simply fixed length records stacked together.

cymbsys@aol.com
0
 

Expert Comment

by:ashwins
ID: 2746426
Dbase is the default standard for PC Database formats. So you can simply open the table in any package that reads data : Spreadsheets / Databases, etc. For eg. In excel you can open the file as a .dbf (Dbase IV files) make the changes you want and save the file back. It's that simple.

Also, there is no restriction on modifying tables with data in dbase. You only cannot change both the name and data-type at the same time.

Please back up your table before trying out anything, whether its VB / Excel / whatever.
0
 

Author Comment

by:anasazi
ID: 2748442
I do not want to use another package to work with these files - I want to do it all with code, within VB.  Also, I don't think you can change the structure of a dbase table once data has been loaded into it.  From within another package - maybe, with code in VB - no.  

I think that the comment posted by MT MU is the best suggestion.  I have tried using SQL to insert old DB data into new DB table structure and this works.  I would like to accept that comment as the answer - how do I do that?
0
 
LVL 1

Accepted Solution

by:
MT_MU earned 100 total points
ID: 2748684
Just accept my comment as an answer.
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
MS Date Picker 64 bit 32 bit issue 12 63
iPhone excel activation issues 11 123
Problem to line 23 73
Macro Excel - if condition - Start by AND contain 12 44
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
Having trouble getting your hands on Dynamics 365 Field Service or Project Service trial? Worry No More!!!
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Viewers will learn how to maximize accessibility options in an Excel workbook for users with accessibility issues.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question