Recent

Author Topic: TBufDataset not saving  (Read 7026 times)

RedOctober

  • Sr. Member
  • ****
  • Posts: 452
TBufDataset not saving
« on: January 26, 2018, 03:39:27 am »
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

  • Hero Member
  • *****
  • Posts: 11916
Re: TBufDataset not saving
« Reply #1 on: January 26, 2018, 09:28:51 am »
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][+][-]
  1. procedure TForm1.FormCreate(Sender: TObject);
  2. begin
  3.   with BufDataset1 do
  4.     begin
  5.       Filename := 'test.dat';
  6.       if not FileExists(FileName) then
  7.         CreateDataset;
  8.       Open;
  9.       Append;
  10.       BufDataset1CharSet.AsString := 'WIN1252';
  11.       Post;
  12.       MergeChangeLog;
  13.     end;
  14. end;
  15.  

RedOctober

  • Sr. Member
  • ****
  • Posts: 452
Re: TBufDataset not saving
« Reply #2 on: January 26, 2018, 03:34:36 pm »
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

  • Hero Member
  • *****
  • Posts: 11916
Re: TBufDataset not saving
« Reply #3 on: January 26, 2018, 04:26:07 pm »
This is a lot of additional information which would have been helpful if it would have been available already in the first post.

The 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

  • Sr. Member
  • ****
  • Posts: 452
Re: TBufDataset not saving
« Reply #4 on: January 26, 2018, 04:37:59 pm »
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

  • Sr. Member
  • ****
  • Posts: 452
Re: TBufDataset not saving
« Reply #5 on: January 26, 2018, 04:39:27 pm »
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

  • Guest
Re: TBufDataset not saving
« Reply #6 on: January 26, 2018, 05:10:08 pm »
@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

  • Hero Member
  • *****
  • Posts: 11916
Re: TBufDataset not saving
« Reply #7 on: January 26, 2018, 05:31:17 pm »
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

  • Guest
Re: TBufDataset not saving
« Reply #8 on: January 26, 2018, 05:53:05 pm »
@wp
That explains why it worked for me.

RedOctober

  • Sr. Member
  • ****
  • Posts: 452
Re: TBufDataset not saving
« Reply #9 on: January 26, 2018, 06:03:34 pm »
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

  • Guest
Re: TBufDataset not saving
« Reply #10 on: January 26, 2018, 06:17:58 pm »
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][+][-]
  1. set path=C:\FPC\3.0.4\bin\i386-win32\;
  2. 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
« Last Edit: January 26, 2018, 06:26:56 pm by GetMem »

RedOctober

  • Sr. Member
  • ****
  • Posts: 452
Re: TBufDataset not saving
« Reply #11 on: January 26, 2018, 06:26:52 pm »
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

  • Guest
Re: TBufDataset not saving
« Reply #12 on: January 26, 2018, 06:29:32 pm »
Quote
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?
fpcupdeluxery has a more polished GUI, IIRC the functionality is the same. 

RedOctober

  • Sr. Member
  • ****
  • Posts: 452
Re: TBufDataset not saving
« Reply #13 on: January 26, 2018, 06:33:52 pm »
I'm building toward a production version ... do you recommend using "Fixes" only, or go straight to "Trunk" ?  Which do you use yourself?

balazsszekely

  • Guest
Re: TBufDataset not saving
« Reply #14 on: January 26, 2018, 06:39:29 pm »
Quote
I'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.

 

TinyPortal © 2005-2018