× Discussions for CodeTyphon Object Pascal Programming Language

Question BufDataset error?

  • prekox maximus
  • Topic Author
  • Away
  • New Member
  • New Member
More
2 weeks 1 day ago #17294 by prekox maximus
BufDataset error? was created by prekox maximus
Hi!
Has the BufDataset unit changed since version 7.5?
7.6 etc. versions, it works in a different way, because it writes the contents of the BufDataset to the disk, but it cannot read it back! But it worked fine in version 7.5!
const
  BUFFERFAJLNEV = 'tempbufadatok.bds';
//.....
var
  Form1: TForm1;
  BufDataSet1: TBufDataset;
  szamlalo:integer;

procedure TForm1.FormCreate(Sender: TObject);
begin
  szamlalo:= 0;
  BufDataSet1 := TBufDataset.Create(nil);
  BufDataSet1.FileName:= BUFFERFAJLNEV;
  if FileExists(BUFFERFAJLNEV) = true then
  begin
    BufDataSet1.LoadFromFile(BUFFERFAJLNEV,dfBinary);
    BufDataSet1.IndexFieldNames:='ID';
    MemDataSource1.DataSet:= BufDataSet1;
    BufDataSet1.Last;
    szamlalo:= BufDataSet1.FieldByName('ID').AsInteger;
  end
  else
  begin
    BufDataSet1.FieldDefs.Add('ID', ftInteger,3);
    BufDataSet1.FieldDefs.Add('VRHCIK',ftString,13);
    BufDataSet1.FieldDefs.Add('MEGNEVEZES',ftString,50);
    BufDataSet1.FieldDefs.Add('VRHFME',ftstring,7);
    BufDataSet1.FieldDefs.Add('EGYSEGAR',ftString,7);
    BufDataSet1.FieldDefs.Add('TETELERTEK',ftString,5);
    BufDataSet1.IndexFieldNames:='ID';
    BufDataSet1.CreateDataset;
    MemDataSource1.DataSet:= BufDataSet1;
  end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  BufDataSet1.Free;
end;

Please Log in or Create an account to join the conversation.

  • Matis A.
  • Matis A.'s Avatar
  • Away
  • Moderator
  • Moderator
More
2 weeks 1 day ago #17295 by Matis A.
Replied by Matis A. on topic BufDataset error?
Please, try and the latest CodeTyphon Ver 7.90 

PilotLogic Core Programmer

Please Log in or Create an account to join the conversation.

  • prekox maximus
  • Topic Author
  • Away
  • New Member
  • New Member
More
2 weeks 11 hours ago #17297 by prekox maximus
Replied by prekox maximus on topic BufDataset error?
I also tried with the latest version, the same thing happens...

Please Log in or Create an account to join the conversation.

  • Matis A.
  • Matis A.'s Avatar
  • Away
  • Moderator
  • Moderator
More
2 weeks 8 hours ago #17300 by Matis A.
Replied by Matis A. on topic BufDataset error?
Give us time to test and report

PilotLogic Core Programmer

Please Log in or Create an account to join the conversation.

  • prekox maximus
  • Topic Author
  • Away
  • New Member
  • New Member
More
1 week 2 days ago #17307 by prekox maximus
Replied by prekox maximus on topic BufDataset error?
Any results?

Please Log in or Create an account to join the conversation.

  • prekox maximus
  • Topic Author
  • Away
  • New Member
  • New Member
More
3 days 4 hours ago #17308 by prekox maximus
Replied by prekox maximus on topic BufDataset error?
the TBufDataset component works when I drop it on the form or the Datamodule, but when created from code it works differently and I don't know what the difference is...

Please Log in or Create an account to join the conversation.

  • prekox maximus
  • Topic Author
  • Away
  • New Member
  • New Member
More
3 days 1 hour ago #17309 by prekox maximus
Replied by prekox maximus on topic BufDataset error?
Hi!
I have attached an example code.
Compiled on version 7.5, it works fine, compiled on version 7.9, it cannot open the saved file! 

File Attachment:

File Name: BufDataset_error.zip
File Size:231 KB

File Attachment:

File Name: BufDataset_error.zip
File Size:231 KB
Attachments:

Please Log in or Create an account to join the conversation.

  • prekox maximus
  • Topic Author
  • Away
  • New Member
  • New Member
More
2 days 3 hours ago #17310 by prekox maximus
Replied by prekox maximus on topic BufDataset error?
An interesting thing is that it works fine in Lazarus 2.2.2, it works fine in CodeTyphon 7.5, it doesn't work until 7.6 - 7.9!

????

Please Log in or Create an account to join the conversation.

  • Matis A.
  • Matis A.'s Avatar
  • Away
  • Moderator
  • Moderator
More
1 day 23 hours ago - 1 day 23 hours ago #17311 by Matis A.
Replied by Matis A. on topic BufDataset error?
Sorry for the delay 
we have a "small" problem with Internet line in our LAB.

You must Always Define  FieldDefs



  Form1: TForm1;
  BufDataSet1: TBufDataset;
implementation

{$R *.frm}

{ TForm1 }

procedure TForm1.FormCreate(Sender: TObject);
begin
  BufDataSet1 := TBufDataset.Create(nil);
  BufDataSet1.FileName:= BUFFERFFILENAME;

  BufDataSet1.FieldDefs.Add('ID', ftInteger,3);
  BufDataSet1.FieldDefs.Add('VRHCIK',ftString,13);
  BufDataSet1.FieldDefs.Add('MEGNEVEZES',ftString,50);
  BufDataSet1.FieldDefs.Add('VRHFME',ftstring,7);
  BufDataSet1.FieldDefs.Add('EGYSEGAR',ftString,7);
  BufDataSet1.FieldDefs.Add('TETELERTEK',ftString,5);
  BufDataSet1.IndexFieldNames:='ID';

  BufDataSet1.CreateDataset;
  MemDataSource1.DataSet:= BufDataSet1;

end;   
 

We test the attach fixed project with
CT 7.9 and with LAB CodeTyphon 8.00
on Win11 ent
 

PilotLogic Core Programmer
Last edit: 1 day 23 hours ago by Matis A..

Please Log in or Create an account to join the conversation.

  • prekox maximus
  • Topic Author
  • Away
  • New Member
  • New Member
More
1 day 5 hours ago #17314 by prekox maximus
Replied by prekox maximus on topic BufDataset error?
This code doesn't work until 7.6 - 7.9..
procedure TForm1.FormCreate(Sender: TObject);
begin
  BufDataSet1 := TBufDataset.Create(nil);
  BufDataSet1.FileName:= BUFFERFFILENAME;
  if FileExists(BUFFERFFILENAME) = true then
  begin
    BufDataSet1.LoadFromFile(BUFFERFFILENAME,dfAny);  //indicates an error at this line
    BufDataSet1.IndexFieldNames:='ID';
    MemDataSource1.DataSet:= BufDataSet1;
  end
  else
  begin
    BufDataSet1.FieldDefs.Add('ID', ftInteger,3);
    BufDataSet1.FieldDefs.Add('VRHCIK',ftString,13);
    BufDataSet1.FieldDefs.Add('MEGNEVEZES',ftString,50);
    BufDataSet1.FieldDefs.Add('VRHFME',ftstring,7);
    BufDataSet1.FieldDefs.Add('EGYSEGAR',ftString,7);
    BufDataSet1.FieldDefs.Add('TETELERTEK',ftString,5);
    BufDataSet1.IndexFieldNames:='ID';
    BufDataSet1.CreateDataset;
    MemDataSource1.DataSet:= BufDataSet1;
  end;
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
   BufDataSet1.Free;
end;        

Please Log in or Create an account to join the conversation.

  • Matis A.
  • Matis A.'s Avatar
  • Away
  • Moderator
  • Moderator
More
1 day 3 hours ago - 1 day 3 hours ago #17315 by Matis A.
Replied by Matis A. on topic BufDataset error?
Yes
it's FreePascal 3.3.1
C:\codetyphon\fpcsrc\packages\fcl-db\src\base\bufdataset.pas
Changed from CT ver 7.60

The above propose modify/fix to your code, work OK.

PilotLogic Core Programmer
Last edit: 1 day 3 hours ago by Matis A..

Please Log in or Create an account to join the conversation.

  • prekox maximus
  • Topic Author
  • Away
  • New Member
  • New Member
More
23 hours 6 minutes ago #17316 by prekox maximus
Replied by prekox maximus on topic BufDataset error?
I understand, but how do you read back the saved data from the file? With version 7.5 there was no problem reading back...

Please Log in or Create an account to join the conversation.

  • Matis A.
  • Matis A.'s Avatar
  • Away
  • Moderator
  • Moderator
More
7 hours 36 minutes ago - 7 hours 21 minutes ago #17317 by Matis A.
Replied by Matis A. on topic BufDataset error?
Sorry
more tests....
This source work OK from me.

procedure TForm1.FormCreate(Sender: TObject);
begin
  BufDataSet1 := TBufDataset.Create(nil);

  if FileExists(BUFFERFFILENAME) = true then
  begin
    BufDataSet1.LoadFromFile(BUFFERFFILENAME);
    BufDataSet1.IndexFieldNames:='ID';
    MemDataSource1.DataSet:= BufDataSet1;
  end
  else
  begin
    BufDataSet1.FieldDefs.Add('ID', ftInteger,3);
    BufDataSet1.FieldDefs.Add('VRHCIK',ftString,13);
    BufDataSet1.FieldDefs.Add('MEGNEVEZES',ftString,50);
    BufDataSet1.FieldDefs.Add('VRHFME',ftstring,7);
    BufDataSet1.FieldDefs.Add('EGYSEGAR',ftString,7);
    BufDataSet1.FieldDefs.Add('TETELERTEK',ftString,5);
    BufDataSet1.IndexFieldNames:='ID';
    BufDataSet1.CreateDataset;
    MemDataSource1.DataSet:= BufDataSet1;
  end;
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
   BufDataSet1.SaveToFile(BUFFERFFILENAME);
   BufDataSet1.Free;
end;

end.


 

PilotLogic Core Programmer
Last edit: 7 hours 21 minutes ago by Matis A..
The following user(s) said Thank You: prekox maximus

Please Log in or Create an account to join the conversation.

  • prekox maximus
  • Topic Author
  • Away
  • New Member
  • New Member
More
2 hours 42 minutes ago #17318 by prekox maximus
Replied by prekox maximus on topic BufDataset error?
It is interesting that the SaveToFile method was executed even when the TBufDataSet was released, but after version 7.6 it must be written out in the code...
Thanks for the help, it works!

Please Log in or Create an account to join the conversation.

  • Matis A.
  • Matis A.'s Avatar
  • Away
  • Moderator
  • Moderator
More
2 hours ago - 2 hours ago #17319 by Matis A.
Replied by Matis A. on topic BufDataset error?
Always you can use the old file bufdataset.pas from CT 7.50

a) put the old 
C:\codetyphon\fpcsrc\packages\fcl-db\src\base\bufdataset.pas
from CT 7.6 to your project folder

b) Rename bufdataset.pas to mybufdataset.pas

c) Use mybufdataset.pas file to you project.

Have fun...

PilotLogic Core Programmer
Last edit: 2 hours ago by Matis A..

Please Log in or Create an account to join the conversation.