Jump to content
jesu

D 11.3: [FireDAC][DatS]-2. Object [myfileld] is not found

Recommended Posts

Hello. I have a program with a clean TFDMemTable connected to a DbGrid just to test different files

type
Mem: TFDMemTable;
...
procedure tDConversor.ProcAbrirMem(const pa_fichero: string);
begin
with Mem do
begin
if Active then Close;
LoadFromFile(pa_fichero);
end;
end;

This worked fine in previous versions, but in 11.3 when I load several files with different structure I get errors. It seems that now LoadFromFile is not cleaning previous field definitions. Can anyone confirm it?

I'm also seeing similar errors with this code: Mem.CopyDataSet(CDS, [coStructure, coRestart, coAppend]);


Thanks.

Share this post


Link to post

After doing some more tests I've also got the same error in 11.2, so this might be not completely new. It's easier to reproduce if any of the files contains BLOB fields.

Share this post


Link to post

RAD 11.3 --> No problem with FDMemtables and LoadFiles JSON/XML types!

type
  TForm1 = class(TForm)
    DBGrid1: TDBGrid;
    DataSource1: TDataSource;
    Button1: TButton;
    FDStanStorageBinLink1: TFDStanStorageBinLink;
    FDStanStorageXMLLink1: TFDStanStorageXMLLink;
    FDStanStorageJSONLink1: TFDStanStorageJSONLink;
    Button2: TButton;
    Button3: TButton;
    Button4: TButton;
    FDMemTable1: TFDMemTable;
    DBMemo1: TDBMemo;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
  private
    procedure FDMemTableOpenMyFile(const AFileName: string);
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FDMemTableOpenMyFile(const AFileName: string);
begin
  DBMemo1.DataSource := nil;
  //
  FDMemTable1.LoadFromFile(AFileName);
  //
  if FDMemTable1.FieldDefs.IndexOf('myBlob') > -1 then
    begin
      DBMemo1.DataSource := DataSource1;
      DBMemo1.DataField  := 'myBlob';
    end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  FDMemTableOpenMyFile('..\..\MyData.json'); // id-integer, names-string
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  FDMemTableOpenMyFile('..\..\MyData.xml'); // birthday-date, money-currency
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
  FDMemTableOpenMyFile('..\..\MyData2.json'); // blob, id, names
end;

procedure TForm1.Button4Click(Sender: TObject);
begin
  FDMemTableOpenMyFile('..\..\MyData2.xml');  // blob, id, names
end;

end.

 

Project1_MKrfLCarIG.gif

Share this post


Link to post

I use sfBinary. Even so, it doesn't happen with every file. It doesn't make sense, but it seems related to the data contained or maybe to the number of records, I'm not sure.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×