2011. március 7., hétfő

How to modify the structure of a Paradox table at runtime


I am upgrading an application and need to add fields to a Paradox TTable database. The application should inspect the existing database file structure and upgrade the customers existing database if necessary.


First, open the files using a TTables exclusively, and check for fields. I was adding fields so I used the following code:

with tblEmployer do
  lFoundAddCalcMethod := FindField('RetireCalcMethod') <> nil;
  lFoundRetireFundMethod := FindField('RetireFundMethod') <> nil;

If I was altering a field (for example, say I wanted to make a field change from Integer to String), you could assing the result of FindField to a TField variable and check it. Then I alter the table as needed:

if not lFoundAddCalcMethod then

and the SQL part of the TQuery:

alter table "MAXXEMPL.DB"
add RetireCalcMethod character(2),
add RetireFundDollar Float,
add RetireFundPercent Float,
add LocalTaxMthd character(2);

Nincsenek megjegyzések:

Megjegyzés küldése