Programming => Databases => Topic started by: egsuh on April 01, 2017, 06:11:45 pm
Title: TBufDataSet.Clear
Post by: egsuh on April 01, 2017, 06:11:45 pm
The TBufDataSet.Clear seems the equivalent of EmptyDataSet or EmptyTable of Delphi, i.e. remove all records leaving the dataset structure. But this seems to remove field definitions as well. Or, it does nothing.
I don't think that HatForCat's code works for TBufDataset because it does not understand SQL. Instead iterate through all records and delete them (untested...):
Title: Re: TBufDataSet.Clear
Post by: Thaddy on April 01, 2017, 06:49:23 pm
Calling clear on a TBufDataset deletes its content from memory and resets *everything*. You probably forgot to save to file or save (commit) to an underlying dataset. The reason is that the Field Defs are cleared too. The fastest way I know in your case is to copy the fielddefs to a temp TFielddefs, call clear and re-assign the fielddefs. Something like: