I don't think you can, I think you need to close the data set, delete all data, add the extra fields and then re-create the dataset. But you can always store the contents of the primary dataset into a secondary dataset, re-create the primary dataset to comply with specifications and then re-populate it with data from the secondary dataset. This is how I've done it before and I clearly remember receiving an error if trying to add a field to a already "created" dataset. Unfortunately I can't find the code because, well, it has been changed loooong time ago, it doesn't exist anymore.
Google for "runtime TClientDataSet" and you'll find some code. Try running it on a "live" dataset. If it fails you know you have to go my way (ie: with a secondary dataset). -- Cosmin Prund > -----Original Message----- > From: [EMAIL PROTECTED] [mailto:delphi-db- > [EMAIL PROTECTED] On Behalf Of Alan Colburn > Sent: Wednesday, July 04, 2007 12:51 AM > To: Moderated discussion list about database programming with Borland's > Delphi > Subject: Adding Fields to ClientDataSets > > Hi folks -- > > Can anyone show me how to add fields at runtime to an open, already > existing > client data set being stored via the SaveToFile method? I'd like a user > to > be able to see a DBGrid and, with the click of a menu item, add a new > field--without losing anything already in the DB. > > Thanks, as always -- Al > > _______________________________________________ > Delphi-DB mailing list > [email protected] > http://www.elists.org/mailman/listinfo/delphi-db _______________________________________________ Delphi-DB mailing list [email protected] http://www.elists.org/mailman/listinfo/delphi-db
