TSQLQuery and TCSVDataSet lazarus / 16-Databases ---------------------------------------------------------------------- egsuh · 2023-04-24 03:53 I checked that SaveToStream and LoadFromStream of TBufDataSet and TSQLQuery are compatible, as they are not virtual methods. Is there the same compatibility between TCSVDataSet and TSQLQuery? I cannot find the hierarchy of TCSVDataSet. ---------------------------------------------------------------------- TRon · 2023-04-24 05:28 Hierarchy as in class hierarchy ? if so then https://www.freepascal.org/daily/packages/fcl- db/csvdataset/tcsvdataset.html TCSVDataset -> TCustomCSVDataset -> TBufDataset -> TCustomBufDataset -> TDBDataset -> TDataSet -> TObject It does use other names for the stream/file load/save functions though (LoadFromCSVStream, LoadFromCSVFile, SaveToCSVStream and SaveToCSVFile). ---------------------------------------------------------------------- egsuh · 2023-04-24 06:30 QuoteHierarchy as in class hierarchy ? if so then https://www.freepascal.org/daily/packages/fcl- db/csvdataset/tcsvdataset.html Thank you for the information. You are right.  CSVDataSet1.LoadFromStream(SQLQuery1) does not work.  But CSVDataSet1.CopyFromDataSet(BufDataSet1) works. It's really interesting. When I edited in the BufDataSet, and copy it to SQLQuery and ApplyUpdates like following, this works. BufDataSet1.SaveToStream(AStrm); SQLQuery1.LoadFromStream(AStrm); SQLQuery1.ApplyUpdates; In this case, delete, update, or insertions are processed correctly. Probably the editings done on the TBufDataSet is stored and copied to TSQLQuery. So I can use the cashed updates with the SQLquery, with proper InsertSQL, etc. I expected this works without any definition of InsertSQL, DeleteSQL, or UpdateSQL using IndexFields, but it does not seem to work. Once I make CopyFromDataSet, this functionality goes away --- but I can delete all pre-existing records and call ApplyUpdate, only with InsertSQL.