Recent

Author Topic: Using TMemDataset  (Read 1207 times)

rdxdt

  • New member
  • *
  • Posts: 8
Using TMemDataset
« on: June 24, 2025, 03:25:10 pm »
Hi i created the field defs on my TMemDataSet, Assuming it serves a purpose like TClientDataSet from VCL or TFDMemTable from FireDAC, now when i try to append a record to it, it gives me field not found.
on TClientDataSet i would call CreateDataSet and then it would work normally, how can i proper use the TMemDataSet to have a dataset in memory with the field defs that i defined?
Thanks

egsuh

  • Hero Member
  • *****
  • Posts: 1623
Re: Using TMemDataset
« Reply #1 on: June 26, 2025, 08:40:27 am »
TBufDataSet is recommended instead of TMemDataSet.

TBufDataSet.CreateDataSet will create dataset.

Thaddy

  • Hero Member
  • *****
  • Posts: 17396
  • Ceterum censeo Trump esse delendam
Re: Using TMemDataset
« Reply #2 on: June 26, 2025, 09:13:51 am »
Correct. TMemdataset has many flaws / limitations that  you need to be aware of.
Use TBufDataset instead.
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.

rdxdt

  • New member
  • *
  • Posts: 8
Re: Using TMemDataset
« Reply #3 on: June 26, 2025, 12:15:48 pm »
Thanks for all the replies folks, i will use the TBufDataset then.

LacaK

  • Hero Member
  • *****
  • Posts: 698
Re: Using TMemDataset
« Reply #4 on: June 30, 2025, 11:30:33 am »
To respond to original question:
Code: Pascal  [Select][+][-]
  1.   MemDs := TMemDataset.Create(nil);
  2.   MemDS.FieldDefs.Add('ID',ftInteger);
  3.   MemDS.FieldDefs.Add('NAME',ftString,50);
  4.   MemDS.CreateTable;
  5.   MemDS.Open;

Richard Marriott

  • New member
  • *
  • Posts: 9
Re: Using TMemDataset
« Reply #5 on: July 04, 2025, 01:54:20 am »
There is a good tutorial on this website on how to get all the TDataset descendants (including TMemDataset) up and running. Look at TUTORIALS on the main menu.

TDataset7.Wordpress.com

Thaddy

  • Hero Member
  • *****
  • Posts: 17396
  • Ceterum censeo Trump esse delendam
Re: Using TMemDataset
« Reply #6 on: July 04, 2025, 05:08:11 pm »
There are better tutorials on OUR wiki, including a warning that TMemdataset has severe limitations and you should consider TBufDataset for real-world applications. And looks to me more like you expect.
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.

Richard Marriott

  • New member
  • *
  • Posts: 9
Re: Using TMemDataset
« Reply #7 on: July 06, 2025, 01:42:52 am »
I wasn't suggesting that the OP should not try the Wiki first, but the Wiki doesn't always show the answer to the exact question needing to be answered. There are many other sources on the Web that can give insights into Lazarus programming. I suggested the above website because it DOES answer the specific question in a way that is easy for newbies to understand. In many cases the Wiki is written by experienced Lazarus programmers and aimed at other experienced programmers, and it takes a newbie (like me) a fair amount of time to get his/her head around the answer, The more alternative sources the more angles that can be seen to a problem.

Thaddy

  • Hero Member
  • *****
  • Posts: 17396
  • Ceterum censeo Trump esse delendam
Re: Using TMemDataset
« Reply #8 on: July 06, 2025, 08:44:44 am »
The wiki is written by - mostly but not always - experienced programmers with the intention to document features of the language in such a way that it is also understandable for beginners.
It is also a source of documentation but not official documentation.
(Beginners should not choose TMemDataSet is one such advice)

E.g. this entry is quite comprehensive if you still want to use it:
https://wiki.freepascal.org/How_to_write_in-memory_database_applications_in_Lazarus/FPC
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.

 

TinyPortal © 2005-2018