How can I access to FUpdateBuffer of TBufDataset? lazarus / 16-Databases ---------------------------------------------------------------------- taqtaq · 2012-12-15 14:41 How can I access to FUpdateBuffer of TBufDataset? I want to modify the  Applyupdates method from TBufDataset and I need to access to FUpdateBuffer to manage  records that i want to save into the db and wich not, but i can't. I hope to explain I have  a function to copy a record to a tbufdataset. I use it to copy only records allocated into a bufdataset or Tsqlquery, because if i use loadfromstream, it moves all data from the database and i don't want that, i need only a packetrecord saved. The function is very simple and needs work: Code: [Select] procedure CopioRegistro(Datasetorigen, Datasetdestino: TBufDataSet); var   ar: Integer; begin   if (Datasetorigen <> nil) and (Datasetdestino <> nil) then   begin     Datasetdestino.Append;      for ar := 0 to Datasetorigen.FieldCount - 1 do     begin       if (Datasetdestino.Fields.FindField(Datasetorigen.Fields[ar].FieldName) <> nil) then         Datasetdestino.FieldByName(Datasetorigen.Fields[ar].FieldName).Value := Datasetorigen.FieldByName           (Datasetorigen.Fields[ar].FieldName).Value;     end;     Datasetdestino.post;   end; end; procedure CopioTabla(Tablaorigen, Tabladestino: TBufDataSet); begin   if (Tablaorigen = nil) or (Tabladestino = nil) then  Exit;   Tablaorigen.Active := True;   Tabladestino.Active := True;   Tablaorigen.First;   for ar := 1 to tablaorigen.RecordCount do   begin     CopioRegistro(tablaorigen, tabladestino);     Tablaorigen.Next;   end; end; After copying all, i want to modify some records for apply to database, but after to use the funcion "CopioTabla" the records are marked as inserted in FUpDateBuffer of TBufDataset and I don't want it because then, when move all to SQLQuery to use applyupdates, the sqlquery considers the records should be inserted but not updated. The mechanism is: 1 : Open SQLQuery from Database. 2 : Save packetrecords into TBufDataset with "CopioTabla". (only few records) 3 : Close SQLQuery. (Close transaction too) 4 : Readfromstream from TBufDataset into SQLQuery. 5 : Work with new datapacket. (modify, delete, insert records) 6 : Open Transaction 7 : Applyupdates (PROBLEM: all the records are consideres like inserted) Well, I hope you can understand me Thanks ---------------------------------------------------------------------- Foxy · 2012-12-15 22:57 Hi taqtaq Short answer is you cannot access it as it is a 'private' member in the TCustomBufDataset object (without exposing it through  'protected' Get/Set routines - That route could be dangerous) You might try something like the following :- Scan your BufDataset exposing the the TDataSet BookMarks. For every record whose BookMark.Flag = bfInserted change that BookMark.Flag := bfCurrent and add the record to your own create stream.  When you have scanned the whole BufDataSet then use SaveToStream to point your stream at the SQLQuery. No idea if it works but better than exposing a private dynamic array. Good Luck Martin Fox