TBufDataset with Invalid character on Post and crash lazarus / 16-Databases ---------------------------------------------------------------------- talisjonatas · 2025-07-09 21:06 Hi everyone, I'm having an issue with TBufDataset (which does not happen with TMemDataset), where all string fields are saved with invalid characters after posting the record. Some fields are saved correctly, others are not. Tested using Lazarus 4.0. I've attached both a code snippet and a sample project to reproduce the issue. 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 procedure TForm1.Button1Click(Sender: TObject);var i: integer;begin i:= 0; BufDa taset1.Close; BufDataset1.CreateDataset; BufDataset1.Open;  repeat  if not BufDataset1.IsEmpty then   BufDataset1.Append;  BufDataset1.Edit;   BufDataset1.FieldByName('name').AsString:= 'Talis ' + IntToStr(i);  BufDataset1.FieldByName('lastname').AsString:= 'Gomes';   BufDataset1.Post;   inc(i) until i > 5;end; In attachment image the error and test project Any suggestions or tips would be greatly appreciated. Very thanks Talis ---------------------------------------------------------------------- Zvoni · 2025-07-10 06:01 I'm trying to wrap my mind around: 1) You close the (active?) Dataset 2) You create the Dataset anew using its FieldDefs?!?!??! 3) You open the Dataset 4) You check if the Dataset is NOT empty --> has content?!?!? Why? 5) If it has content start Append 6) No matter the result from step 5, you go into Edit-Mode?!?!??! ....this is some really borked code.... ---------------------------------------------------------------------- talisjonatas · 2025-07-10 11:35 Quote from: Zvoni on July 10, 2025, 08:01:40 am1) You close the (active?) Dataset 2) You create the Dataset anew using its FieldDefs?!?!??! 3) You open the Dataset 4) You check if the Dataset is NOT empty --> has content?!?!? Why? 5) If it has content start Append 6) No matter the result from step 5, you go into Edit-Mode?!?!??! Hello, I understand your concerns. The example is just an adaptation of a real code scenario. If you follow all the points you mentioned, the result will be exactly the same. If there is a way to get around the problem I would be grateful for your help. ---------------------------------------------------------------------- paweld · 2025-07-10 11:49 Your example works fine for me, both in Lazarus 4.0/FPC 3.2.2 and Lazarus 4.99 (trunk)/FPC 3.2-fixes. I am attaching another example, you can check if it works correctly for you. ---------------------------------------------------------------------- talisjonatas · 2025-07-10 14:53 Quote from: paweld on July 10, 2025, 01:49:42 pmYour example works fine for me, both in Lazarus 4.0/FPC 3.2.2 and Lazarus 4.99 (trunk)/FPC 3.2-fixes. I am attaching another example, you can check if it works correctly for you. I managed to understand the problem. It's a bug that happens if you click "Create Dataset" in Design Time, and it crashes. Thank you very much for providing the demo, as it was the only way I could understand the problem.