Jump to content
Sign in to follow this  
Himie

Using FDMemTable

Recommended Posts

  • Members
  •  0
  • 2 posts

Hi There (Reposting here as think might reflect more on databases than datasets where posted previously)

I am using (or trying to use) FDMemTables and it is not cooperating.  I am using the Community edition of Delphi 10.3 with Windows 10.  I have a DataModule in which I have placed the respective FDMemTables and in the OnCreate event I have put the Field Definitions and create the table as below:

 

with fdmAdmin.FieldDefs do begin       // fdmAdmin
      clear;
      Add('ID',ftString,4);
      Add('Num',ftString,4);
      Add('SaveLocation',ftString,80);
      Add('LastPurchOrder',ftString,30);
      Add('LastInvoice',ftString,30);
      Add('LastReceipt',ftString,30);
      Add('CurrentJournal',ftString,30);
   end;
   fdmAdmin.CreateDataSet;

 

In another Unit (which references the DataModule1 in its Implementation Uses) I have the following code:

 

DataModule1.fdmAdmin.Active := true;
if DataModule1.fdmAdmin.RecordCount < 1 then begin   // if no records means starting and no saving previously done
      DataModule1.fdmAdmin.Append;
      DataModule1.fdmAdmin.Edit;
      DataModule1.fdmAdmin['LastInvoice'] := '0000';
      DataModule1.fdmAdmin['LastPurchOrder'] := '0000';
      DataModule1.fdmAdmin['LastReceipt'] := '0000';
      DataModule1.fdmAdmin.Post;
end;

 

I get the message 'Cannot open dataset [TFDMemTable].  A DataTable or a DataView must be supplied.  Hint:  if this is a TFDMemTable, use CreateDataSet or CloneCursor to open dataset.'

There is a CreateDataSet in the DataModule1 code.  Anyone point me in the right direction here?  Thanks heaps.

Himie

Share this post


Link to post

Hi Ralf

No, I have not referenced the CachedUpdates at all

Cheers

Himie

Share this post


Link to post
3 hours ago, Himie said:

I get the message 'Cannot open dataset [TFDMemTable].  A DataTable or a DataView must be supplied.  Hint:  if this is a TFDMemTable, use CreateDataSet or CloneCursor to open dataset.'

There is a CreateDataSet in the DataModule1 code.  Anyone point me in the right direction here?  Thanks heaps.

Place a break point in the DataModule most probably you didn't excecuted the code there and fdmAdmin.FieldDefs remains empty. That's the only way you get this error message.

Share this post


Link to post

Thanks

I hvae the DataModule1 in the auto-create forms part so should execute.  Will investigate this further.  Thanks for the tip.

Himie

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
Sign in to follow this  

×