creating a dynamic table
Posted on 2003-03-14
I'm trying to get data from different files into one table.
A dBASE table is created if it is not existing and further on in the program, for each new file that is opened, another column should be created having the name of the file that is being opened.
I've already tried it with:
Table1.Active := false;
if Table1.FindField(Fnshort) = nil then begin //where Fnshort is the current filename
NewField := TStringField.Create(self);
Newfield.FieldName := Fnshort;
NewField.FieldKind := fkData;
this doesn't work.
Another way I've tried was with:
Table1.FieldDefs.AddFieldDef.Name := Fnshort;
Table1.FieldDefs.AddFieldDef.DataType := ftFloat;
but I guess that doesn't work because I am not using CreateTable afterwards (as that would erase the already added data).
Can anyone tell me whether it is possible to add a column to a table after it has been created (without creating a new table and copying the old one into the new one) & if so, how do I do that?