Welcome, Guest
Username: Password: Remember me
Discussions for CodeTyphon Object Pascal Programming Language
  • Page:
  • 1

TOPIC:

BufDataset error? 2 years 3 weeks ago #17294

  • prekox maximus
  • prekox maximus's Avatar Topic Author
  • Visitor
  • Visitor
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.

BufDataset error? 2 years 3 weeks ago #17295

  • Matis A.
  • Matis A.'s Avatar
  • Away
  • Moderator
  • Moderator
  • Posts: 1087
  • Thank you received: 156
Please, try and the latest CodeTyphon Ver 7.90 
PilotLogic Core Programmer

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

BufDataset error? 2 years 3 weeks ago #17297

  • prekox maximus
  • prekox maximus's Avatar Topic Author
  • Visitor
  • Visitor
I also tried with the latest version, the same thing happens...

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

BufDataset error? 2 years 3 weeks ago #17300

  • Matis A.
  • Matis A.'s Avatar
  • Away
  • Moderator
  • Moderator
  • Posts: 1087
  • Thank you received: 156
Give us time to test and report
PilotLogic Core Programmer

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

BufDataset error? 2 years 2 weeks ago #17307

  • prekox maximus
  • prekox maximus's Avatar Topic Author
  • Visitor
  • Visitor
Any results?

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

BufDataset error? 2 years 1 week ago #17308

  • prekox maximus
  • prekox maximus's Avatar Topic Author
  • Visitor
  • Visitor
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.

BufDataset error? 2 years 1 week ago #17309

  • prekox maximus
  • prekox maximus's Avatar Topic Author
  • Visitor
  • Visitor
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.

BufDataset error? 2 years 1 week ago #17310

  • prekox maximus
  • prekox maximus's Avatar Topic Author
  • Visitor
  • Visitor
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.

BufDataset error? 2 years 1 week ago #17311

  • Matis A.
  • Matis A.'s Avatar
  • Away
  • Moderator
  • Moderator
  • Posts: 1087
  • Thank you received: 156
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

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

Last edit: by Matis A..

BufDataset error? 2 years 1 week ago #17314

  • prekox maximus
  • prekox maximus's Avatar Topic Author
  • Visitor
  • Visitor
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.

BufDataset error? 2 years 1 week ago #17315

  • Matis A.
  • Matis A.'s Avatar
  • Away
  • Moderator
  • Moderator
  • Posts: 1087
  • Thank you received: 156
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

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

Last edit: by Matis A..

BufDataset error? 2 years 1 week ago #17316

  • prekox maximus
  • prekox maximus's Avatar Topic Author
  • Visitor
  • Visitor
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.

BufDataset error? 2 years 1 week ago #17317

  • Matis A.
  • Matis A.'s Avatar
  • Away
  • Moderator
  • Moderator
  • Posts: 1087
  • Thank you received: 156
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
The following user(s) said Thank You: prekox maximus

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

Last edit: by Matis A..

BufDataset error? 2 years 1 week ago #17318

  • prekox maximus
  • prekox maximus's Avatar Topic Author
  • Visitor
  • Visitor
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.

BufDataset error? 2 years 1 week ago #17319

  • Matis A.
  • Matis A.'s Avatar
  • Away
  • Moderator
  • Moderator
  • Posts: 1087
  • Thank you received: 156
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
The following user(s) said Thank You: prekox maximus

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

Last edit: by Matis A..
  • Page:
  • 1