using Tbufdataset as memtable lazarus / 16-Databases ---------------------------------------------------------------------- mangakissa · 2013-11-13 19:24 Im Delphi I'm very font of using VirtualTable (memorytable). With Virtualtable.assign(Query) I can fill my memorytable with fields and their data from the datacomponent Query. But TBufdataset doesn't except it. This is my procedure: Code: [Select]procedure TScreenLevels.LoadScreenTable; var  Query : TSQLQuery; begin   FTableLoaded := true;   try     try       Query               := TSQLQuery.create(nil);       query.DataBase      := FIBConn;       Query.Transaction   := FTransaction;       Query.SQL.Text      := 'SELECT * FROM schermen ORDER BY scherm';       Query.Active        := true;       FMemdataset.Assign(Query);       FMemdataset.Active  := true;       FMemdataset.IndexFieldNames := 'scherm';       Query.Active        := false;     except       FTableLoaded := false;     end;   finally     Query.free;   end; end; How do I fill Tbufdataset if this is not the right way? ---------------------------------------------------------------------- goodname · 2013-11-14 03:16 Don't know if it is the best method but you could look into streams. query.SaveToStream(); bufDataSet.LoadFromStream(); The TmemDataset and TBufDataset are different so not sure which your actually trying to work with. ---------------------------------------------------------------------- LacaK · 2013-11-14 06:06 For TMemDataset you can use: TMemDataset.CopyFromDataset For TBufDataset you can use: as mentioned by goodname: LoadFromStream (but only from stream to which was data saved from TBufDataset ot its descendant like TSQLQuery) ---------------------------------------------------------------------- mangakissa · 2013-11-14 08:01 TMemtable is fixed (lookup problem) in the next release, so it's not an option. For using TStream to fill a TBufdataset is a little bit strange, but I can manage that. But is TBufdataset not a part of TSQLQuery? ---------------------------------------------------------------------- mangakissa · 2013-11-14 09:15 I Only need the data in memory to read it in several forms. TSQLQuery derives from TBufDataset, so the dataset is already in memory. no transaction will be used and when refreshing the dataset, I only have to call refresh. My solution: Code: [Select]procedure TScreenLevels.LoadScreenTable; begin   try     FMemdataset.DataBase      := FIBConn;     FMemdataset.SQL.Text      := 'SELECT * FROM schermen ORDER BY scherm';     FMemdataset.PacketRecords := -1;     FMemdataset.Active        := true;   except     FTableLoaded := false;   end; end; ---------------------------------------------------------------------- mangakissa · 2016-02-02 21:05 I still need a copy of the dataset into a bufdataset. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i var BufStream : TMemoryStream;begin.......SQLQuery.Active := true;SQLQuery .SaveToStream(BufStream,dfBinary);BufDataset.LoadFromStream(BufStream, dfBinary);.....end;     But I got a runtime error dataformat is not reconised when load the stream. But TMemDataset.CopyFromDataset(dataset,false) did the trick. I only need to have a clear dataset with the same fields without any restrictions of required fields. Now I can append a few records to print some blanc records in my reportbuilder. ---------------------------------------------------------------------- tatamata · 2016-02-03 07:15 ZMQueryDataset, which is direct TBufDataset descendent, has CopyFromDataset method. Plain and simple, you can copy any dataset instantly to ZMQuryDataset.