Recent

Author Topic: BufferDataset error Save and Load from file  (Read 2283 times)

eldonfsr

  • Hero Member
  • *****
  • Posts: 550
BufferDataset error Save and Load from file
« on: September 24, 2024, 03:10:11 am »
I don't know why now bufferdataset give me error save and load from file


paweld

  • Hero Member
  • *****
  • Posts: 1420
Re: BufferDataset error Save and Load from file
« Reply #1 on: September 24, 2024, 07:04:04 am »
What version of lazarus / fpc? In Lazarus trunk / fpc 3.2-fixes version the project works fine - when closing the form it saves to file, when opening it loads from file if file exists
Best regards / Pozdrawiam
paweld

eldonfsr

  • Hero Member
  • *****
  • Posts: 550
Re: BufferDataset error Save and Load from file
« Reply #2 on: September 24, 2024, 02:32:07 pm »
windows lazarus 3.2.2 this error show when save..and close buffer data



rvk

  • Hero Member
  • *****
  • Posts: 6776
Re: BufferDataset error Save and Load from file
« Reply #3 on: September 24, 2024, 02:59:23 pm »
Works fine for me too.

BUT... you shouldn't free mdbtns in your CloseForm !!!!!!!!
The mdbtns is created and controlled (owned) by your form.
NEVER free components that you don't create yourself (with nil as owner parameter).

This is probably the reason for your error (because TForm is trying to clear and free the component while you already did so).

eldonfsr

  • Hero Member
  • *****
  • Posts: 550
Re: BufferDataset error Save and Load from file
« Reply #4 on: September 24, 2024, 03:45:19 pm »
Yes i remove MDBtns.close and MDBtns.free, but  still send me a error on close and another this you can see values show me on dbgrid is not what values i put on fields..
Code: Pascal  [Select][+][-]
  1. Var ic:Integer;
  2. begin
  3.    if( not FileExists(GetCurrentDir+'\BTNSMACROS.db')) then begin
  4.  
  5.     if( MDBtns.Active=false) then begin
  6.  //      MDBtns.FileName:=GetCurrentDir+'\BTNSMACROS.db';
  7. //       MDBtns.LoadFromFile(GetCurrentDir+'\BTNSMACROS.db');
  8.        MDBtns.Open;
  9.        ic:=0;
  10.      if MDBtns.EOF then begin
  11.        MDBtns.Append;
  12.        MDBtns.FieldByName('PageNo').AsInteger:= 0;
  13.        MDBtns.FieldByName('BtnName').AsString:= 'BtnHomeSp1';
  14.        MDBtns.FieldByName('Caption').AsString:= 'Home';
  15.        MDBtns.FieldByName('Macro').AsString:= 'MS0';
  16.        MDBtns.post;
  17.        MDBtns.Append;
  18.        MDBtns.FieldByName('PageNo').AsInteger:= 0;
  19.        MDBtns.FieldByName('BtnName').AsString:= 'BtnMovUnoSp1';
  20.        MDBtns.FieldByName('Caption').AsString:= 'Move 1';
  21.        MDBtns.FieldByName('Macro').AsString:= 'MS30';
  22.        MDBtns.post;
  23.        MDBtns.Append;
  24.        MDBtns.FieldByName('PageNo').AsInteger:= 0;
  25.        MDBtns.FieldByName('BtnName').AsString:= 'BtnMtoDosSp1';
  26.        MDBtns.FieldByName('Caption').AsString:= 'Move 2';
  27.        MDBtns.FieldByName('Macro').AsString:= 'MS35';
  28.        MDBtns.post;
  29.        MDBtns.Append;
  30.        MDBtns.FieldByName('PageNo').AsInteger:= 0;
  31.        MDBtns.FieldByName('BtnName').AsString:= 'BtnMvtCycleSp1';
  32.        MDBtns.FieldByName('Caption').AsString:= 'Move Cycle';
  33.        MDBtns.FieldByName('Macro').AsString:= 'MS40';
  34.        MDBtns.post;
  35.        MDBtns.Append;
  36.        MDBtns.FieldByName('PageNo').AsInteger:= 0;
  37.        MDBtns.FieldByName('BtnName').AsString:= 'BtnMvtLoopSp1';
  38.        MDBtns.FieldByName('Caption').AsString:= 'Loop Cycle';
  39.        MDBtns.FieldByName('Macro').AsString:= 'MS50';
  40.        MDBtns.post;
  41.        MDBtns.Append;
  42.        MDBtns.FieldByName('PageNo').AsInteger:= 0;
  43.        MDBtns.FieldByName('BtnName').AsString:= 'BtnTechPosi1Sp1';
  44.        MDBtns.FieldByName('Caption').AsString:= 'Teach Posi 1';
  45.        MDBtns.FieldByName('Macro').AsString:= 'MS90';
  46.        MDBtns.post;
  47.        MDBtns.Append;
  48.        MDBtns.FieldByName('PageNo').AsInteger:= 0;
  49.        MDBtns.FieldByName('BtnName').AsString:= 'BtnTechPosi2Sp1';
  50.        MDBtns.FieldByName('Caption').AsString:= 'Teach Posi 2';
  51.        MDBtns.FieldByName('Macro').AsString:= 'MS95';
  52.        MDBtns.post;
  53.        MDBtns.Append;
  54.        MDBtns.FieldByName('PageNo').AsInteger:= 0;
  55.        MDBtns.FieldByName('BtnName').AsString:= 'BtnSpeedAccSp1';
  56.        MDBtns.FieldByName('Caption').AsString:= 'Speed Acc';
  57.        MDBtns.FieldByName('Macro').AsString:= 'MS100';
  58.        MDBtns.post;
  59.        MDBtns.Append;
  60.        MDBtns.FieldByName('PageNo').AsInteger:= 0;
  61.        MDBtns.FieldByName('BtnName').AsString:= 'BtnFindSurfSp1';
  62.        MDBtns.FieldByName('Caption').AsString:= 'Find Surface';
  63.        MDBtns.FieldByName('Macro').AsString:= 'MS60';
  64.        MDBtns.post;
  65.      end;
  66.     end else begin
  67.        MDBtns.FileName:=GetCurrentDir+'\BTNSMACROS.db';
  68.        mdbtns.LoadFromFile(GetCurrentDir+'\BTNSMACROS.db');
  69.        MDBtns.Open;
  70.     end;
  71.  
  72.  
  73.    end else begin
  74.      mdbtns.LoadFromFile(GetCurrentDir+'\BTNSMACROS.db' );
  75.      MDBtns.Open;
  76.    end;            
  77.  
  78.  

eldonfsr

  • Hero Member
  • *****
  • Posts: 550
Re: BufferDataset error Save and Load from file
« Reply #5 on: September 24, 2024, 03:48:40 pm »
I download and install lazarus 3.4 still the same problem ....

rvk

  • Hero Member
  • *****
  • Posts: 6776
Re: BufferDataset error Save and Load from file
« Reply #6 on: September 24, 2024, 03:50:14 pm »
Yes i remove MDBtns.close and MDBtns.free, but  still send me a error on close
Doesn't happen here

and another this you can see values show me on dbgrid is not what values i put on fields..
You might want to begin with deleting the existing db file because that code doesn't execute if the file exists.
(And you probably have some fields from before)

This code doesn't correspond with the earlier code so you have changed things around.
So we can't tell what's going on.

BTW. I wouldn't do MDBtns.FieldByName('PageNo').AsString := '4' since PageNo is defined as SmallInt.
You might want to use AsInteger instead.
(FPC will convert this but it's better to be sure)
« Last Edit: September 24, 2024, 03:56:11 pm by rvk »

eldonfsr

  • Hero Member
  • *****
  • Posts: 550
Re: BufferDataset error Save and Load from file
« Reply #7 on: September 24, 2024, 07:39:55 pm »
I create a new project and send me same error when close app is only bufferdata and dbgrid on form..
and also the information is now as was insert on fields... some problems

lazarus 3.4 64 on windows 10





BrunoK

  • Hero Member
  • *****
  • Posts: 698
  • Retired programmer
Re: BufferDataset error Save and Load from file
« Reply #8 on: September 24, 2024, 07:51:15 pm »
I create a new project and send me same error when close app is only bufferdata and dbgrid on form..
and also the information is now as was insert on fields... some problems

lazarus 3.4 64 on windows 10
All I can add is that I tried the last program (Win 10, FPC 3.2.2, laz +- trunk) and there are quite a few errors showing as described by eldonfsr.

I couldn't find what might be wrong to the point of getting all these errors in his code.

eldonfsr

  • Hero Member
  • *****
  • Posts: 550
Re: BufferDataset error Save and Load from file
« Reply #9 on: September 24, 2024, 08:52:05 pm »
I made the same sample on other computer and same results datas not as was input values and when close app same error...

lazarus 3.4 windows 10...

and i made same test typhon and not problem....


TRon

  • Hero Member
  • *****
  • Posts: 4377
Re: BufferDataset error Save and Load from file
« Reply #10 on: September 24, 2024, 08:57:27 pm »
Wasn't there an issue with tbufdataset and persistent fields ? e.g. you had to use createdataset explicitly ? I might remember it wrong though...
« Last Edit: September 24, 2024, 09:02:46 pm by TRon »
Today is tomorrow's yesterday.

eldonfsr

  • Hero Member
  • *****
  • Posts: 550
Re: BufferDataset error Save and Load from file
« Reply #11 on: September 24, 2024, 09:58:44 pm »
Exactly is what i did...

TRon

  • Hero Member
  • *****
  • Posts: 4377
Re: BufferDataset error Save and Load from file
« Reply #12 on: September 25, 2024, 12:25:41 am »
Apologies as it took me some time to locate the corresponding thread.

see here, reported at issue  40450 (and seems to have been fixed by wp).

My mind isn't exactly clear atm so pardon me for not being able to advise how you need to fix that in your current code.

Perhaps someone else is around is able to help you out.
Today is tomorrow's yesterday.

eldonfsr

  • Hero Member
  • *****
  • Posts: 550
Re: BufferDataset error Save and Load from file
« Reply #13 on: September 25, 2024, 12:34:54 am »
Wow i understand what you sad... i made changes and look working let me continue with make better understanding this thinks...

rvk

  • Hero Member
  • *****
  • Posts: 6776
Re: BufferDataset error Save and Load from file
« Reply #14 on: September 25, 2024, 02:45:27 am »
see here, reported at issue  40450 (and seems to have been fixed by wp).
Which should be fixed in version 3.4, shouldn't it?

I made the same sample on other computer and same results datas not as was input values and when close app same error...

lazarus 3.4 windows 10...

and i made same test typhon and not problem....
So that version should be ok.

(I'm on the fixes_3_2 version and it worked fine for me so it should have worked in 3.4 too)

 

TinyPortal © 2005-2018