Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Alter dBase IV table w/data loaded

Posted on 2000-04-20
8
Medium Priority
?
463 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
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
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 400 total points
ID: 2748684
Just accept my comment as an answer.
0

Featured Post

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

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

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…

715 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