TBufDataset not saving lazarus / 16-Databases ---------------------------------------------------------------------- RedOctober · 2018-01-26 02:39 I have attached an example project.  I .CreateDataSet, then .Append then .Post then .MergeChangeLog. Now, when ever I make a change using a data aware control, I try to post the change and my changes are discarded.  I must be missing something very obvious, but I don't know what. ---------------------------------------------------------------------- wp · 2018-01-26 08:28 I see several issues in your code: - You don't specify any filename. So, how do you expect the dataset to be saved? - You call CreateDataset. This erases any data loaded from file even if there is a filename. - Note that you must "open" the dataset when CreateDatasset is not called. - Just for testing: Add a DBGrid to better see whether records are added. 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.FormCreate(Sender: TObject);begin  with BufDataset1 do    begin      Filename := 'test.dat';      if not FileExists(FileName) then        CreateDataset;      Open;      Append;      BufDataset1CharSet.AsString := 'WIN1252';      Post;      MergeChangeLog;    end;end; ---------------------------------------------------------------------- RedOctober · 2018-01-26 14:34 Hi wp.  Here are the answers to your questions: (First let me state that my platform is Windows Server Essentials 2016, Lazarus 1.8, FPC 3.0.4) >> You don't specify any filename. So, how do you expect the dataset to be saved? The dataset is not intended to be saved.  I'm trying to use TBufDataset like I used TClientDataset in Delphi.  It's just a temporary in-memory table, never intended to be saved. >> You call CreateDataset. This erases any data loaded from file even if there is a filename. I have to call CreateDataset when my program starts.  I put this in my form's (or DataModule's) .OnCreate event.  There is no data at that point, so calling .CreateDataset doesn't erase anything.  It just prepares the TBufDataset to be populated. >> Note that you must "open" the dataset when CreateDatasset is not called. Understood.  Explained above. >> Just for testing: Add a DBGrid to better see whether records are added. A single record is definitely being added.  It's values appear in the Data aware controls of my form.  The trouble is, when I change the values in the fields of the form using the data aware controls, then .Post, the values I entered are discarded, and the original values remain. The example project I attached to my Original Post demonstrates the problem. ---------------------------------------------------------------------- wp · 2018-01-26 15:26 This is a lot of additional information which would have been helpful if it would have been available already in the first post. Quote from: RedOctober on January 26, 2018, 03:34:36 pmThe example project I attached to my Original Post demonstrates the problem. Sorry not for me. Maybe my stupidity. But what do you do in this demo and what do you expect to see? The problem with many forum posts is that the posters seem to forget that the readers are not aware of the problem described at all. Please be more verbous. How much is your issue related to a DBCombobox? Recently, there were some fixes of this control, your description reminds me of https://bugs.freepascal.org/view.php?id=30587 or https://bugs.freepascal.org/view.php?id=32383- ---------------------------------------------------------------------- RedOctober · 2018-01-26 15:37 Hi wp: - Start the example project - The default value is WIN1252 - Use the combo box to choose a different value - Click the "Save" button - The value you chose is discarded and the original value is saved. <--- wrong behavior Expected behavior -  When clicking "Save", the new value you select should be saved (ASCII or BIG5).  It should not revert back to WIN1252 I'll now go read the link you gave in your most recent post.  Thanks for your help with this. ---------------------------------------------------------------------- RedOctober · 2018-01-26 15:39 Hi wp: I read the link.  My issue is not related.  I click on the TDBComboBox and then click on the new value that I want.  I do not use the mouse wheel at all. ---------------------------------------------------------------------- balazsszekely · 2018-01-26 16:10 @RedOctober I'm not following you...why do you say it's not saved? If I put a grid linked to the bufdataset, then press the save button, the new value is displayed(ASCII or BIG) in the grid. ---------------------------------------------------------------------- wp · 2018-01-26 16:31 It is fixed in trunk and has been backported to fixes. It's just the same issue which I mentioned above (using the mouse wheel is just another way of selecting another entry). ---------------------------------------------------------------------- balazsszekely · 2018-01-26 16:53 @wp That explains why it worked for me. ---------------------------------------------------------------------- RedOctober · 2018-01-26 17:03 Hi wp and GetMem. In my case, the DBGrid doesn't change when I click "Save" after having selected a different value.  It shows only the original value.  I change the value in the DBGrid, then click "Save", then the new value is saved.  Ok so I think we've found the problem.. now, I have another question: - Just as a phylosophical preference, I prefer avoid disturbing my current Lazarus/FPC platform because I'm afraid of introducing more bugs, however... I have to disturb it to get the bug fixes I need.  So, what I'm wondering is.. - What is "fixes" and how do I get it and install it? - What is "trunk" and how do I get it and install it? Do most people always work on Trunk in an attempt to get all the latest bug fixes? If so, don't they risk getting new bugs in things that were already working and tested? Thanks for your help. ---------------------------------------------------------------------- balazsszekely · 2018-01-26 17:17 Quote- What is "fixes" and how do I get it and install it?Fixes will be merged in the next version of Lazarus. AFAIK you cannot install them directly. Please see here the latest ones: http://wiki.freepascal.org/Lazarus_1.8_fixes_branch Quote- What is "trunk" and how do I get it and install it?If I remember correctly you're on windows. You have multiple choices: 1. Use Fpcupdeluxe, it's a great tool, it will install a separate instance of Lazarus/FPC to a custom folder. Download the appropriate binary from here: https://github.com/newpascal/fpcupdeluxe/releases/tag/v1.6.0m 2. Use the stable version of FPC installed on your computer and always build Lazarus trunk manually   a.) Download a svn client like tortoise svn: https://tortoisesvn.net/downloads.html   b.) Do a checkout from here: https://svn.freepascal.org/svn/lazarus/trunk   c.) build Lazarus like this(create a bat file, change path to fpc): 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 set path=C:\FPC\3.0.4\bin\i386-win32\;make bigide  d.) When you wish to update to the latest version, just right click on the Lazarus folder, then "SVN Update" PS: The first method it's fully automated, all you have to do is press 1-2 buttons, the second one is a bit complicated but much faster ---------------------------------------------------------------------- RedOctober · 2018-01-26 17:26 Thanks GetMem!  I'll use:  fpcupdeluxe-x86_64-win64.exe (BTW... what is the fpcupdeluxery-x86_64-win64.exe ?)  What does the extra "ry" mean? ---------------------------------------------------------------------- balazsszekely · 2018-01-26 17:29 QuoteThanks GetMem!  I'll use:  fpcupdeluxe-x86_64-win64.exe (BTW... what is the fpcupdeluxery-x86_64-win64.exe ?)  What does the extra "ry" mean?fpcupdeluxery has a more polished GUI, IIRC the functionality is the same. ---------------------------------------------------------------------- RedOctober · 2018-01-26 17:33 I'm building toward a production version ... do you recommend using "Fixes" only, or go straight to "Trunk" ?  Which do you use yourself? ---------------------------------------------------------------------- balazsszekely · 2018-01-26 17:39 QuoteI'm building toward a production version ... do you recommend using "Fixes" only, or go straight to "Trunk" ?  Which do you use yourself?Most definitely trunk, but sometimes it will break development. In my opinion it worth the risk, but you should be the one who decide. Another choice is to install both of them in two separate folders, if space is not an issue(3G/folder approximately). Then you could play with different versions. ---------------------------------------------------------------------- wp · 2018-01-26 17:39 If I remember correctly the bug that you suffer from was fixed in a single line change: Open source file dbcombobox.inc, it is in folder lcl/include of your Lazarus installationFind the procedure and add the line FDataLink.Modified as shown below (to be on the safe side, make a backup copy of the file before you change it):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 TDBComboBox.Select;begin  //avoid reseting text when calling select  FDataLink.OnDataChange := nil;  try    if FDataLink.Edit then    begin       FDataLink.Modified;    // <---- ADD THIS LINE       FDataLink.UpdateData;       inherited Select;    end    else    begin       FDatalink.Reset;       DataChange(Self);    end;  finally    FDataLink.OnDataChange := @DataChange;  end;end;Then recompile your program, Lazarus will automatically recompile the modified DBCombobox.When a new version will be released this fix will be contained automatically. "Trunk" is the development version of Lazarus - this is what will be released as Lazarus 1.10 or 2.0. You can get it with svn as described by GetMem. It is remarkably stable, I work with it regularly. But of course, fatal issues can occur from time to time, if they are not fixed within a few days write a message to the Lazarus mailing list. Or you can revert to an older revision with svn easily, normally you don't need the ultra-freshest version. "fixes" is the branch preparing for bug-fix release of the current version, 1.8. You work with it in the same way, but containing less experimental code, its stability should be better than that of trunk although very rare fatal issues cannot be excluded. ---------------------------------------------------------------------- RedOctober · 2018-01-26 21:01 I have installed both Fixes and Trunk.  Under Trunk, another bug is introduced, so I abandoned it.  Under Fixes, the problem with the DBComboBoxes is fixed and my project is working better. Thanks for the help wp and GetMem. ---------------------------------------------------------------------- wp · 2018-01-26 21:12 Quote from: RedOctober on January 26, 2018, 10:01:31 pmUnder Trunk, another bug is introduced, so I abandoned it. What is wrong with trunk? If you don't report it it will only be fixed if somebody else sees and reports it.