Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create a new Field in a TTable, in RUNTIME??? 2

Status
Not open for further replies.

luistsousa

Technical User
May 12, 2003
66
0
0
PT
Hello

I can add new fields to a table with the code in low. However, if I have datas in the other fields of the table, these I will be delete. How I can add new fields without erasing the old data?

TFieldDef *NewField =Table1->FieldDefs->AddFieldDef();
Table1->Active = false;
DataType = ftInteger;
NewField->Name = "new";
Table1->CreateTable();

Many Thanks
 
you create the new table and then copy all the data from the old to the new. that is is you have saved the old table to a different name or the new table is of a different name. Use BatchMove.

tomcruz.net
 
Hi there.

You can use SQL to add a field to an existing table. You would use the ALTER statement. There is an example in the local SQL help file LOCALSQL.HLP , you can find it somewhere in the folder ...\Common Files\Borland Shared\BDE

Or you can the BDE Api function DBIDoRestructure,

Example can be found here

You may need to include bde.hpp and also see this page
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top