Once a TClientDataSet has passed the CreateDataSet stage (if it has successfully been opened, then it must have), modifying the FieldDefs has no effect on your fields (and no, using FieldDefs.Update won't help). The way around it is to create a new, temporary, in-memory TClientDataSet and assign all the FieldDefs across (using FieldDefs.Assign is the quickest way to do this) and then delete/modify/add FieldDefs as required.
Of course, you will also have to copy across other relevant definitions as well as your data. Sadly, when it comes to the data, you can't just use the Data property since the two datasets will no longer match, so you'll have to append each record manually by iterating through the original dataset. After all this you now have to redefine the original dataset according to the temporary dataset. The only difference at this stage is that you can use the Data property to copy across the data from the temporary dataset to the original, but redefined dataset. Note that I have no idea if the above steps work if you're using a provider since I've only performed these steps with in-memory TClientDataSets that don't use providers. Personally I doubt it would work since the new definition would probably conflict with that supplied by the provider. About IndexDefs.Clear. Well, I remember doing something with these at some stage, but I can't tell you if the same issue applies as with FieldDefs, but I would guess it would. -Andreas -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Rohit Gupta Sent: Thursday, 22 August 2002 14:55 To: Multiple recipients of list delphi Subject: [DUG]: Resuing ClientDataset How does one clear previously defined indexes and fields in a clientdataset ? cds.IndexDefs.Clear and cds.FieldDefs.Clear dont seem to work Regards Rohit ====================================================== ================ CFL - Computer Fanatics Ltd. 21 Barry's Point Road, AKL, New Zealand PH (649) 489-2280 FX (649) 489-2290 email [EMAIL PROTECTED] or [EMAIL PROTECTED] ====================================================== ================ --------------------------------------------------------------------------- New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED] Website: http://www.delphi.org.nz To UnSub, send email to: [EMAIL PROTECTED] with body of "unsubscribe delphi" Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/ --------------------------------------------------------------------------- New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED] Website: http://www.delphi.org.nz To UnSub, send email to: [EMAIL PROTECTED] with body of "unsubscribe delphi" Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/