0

I need some help concerning TClientDataSet since after doing extensive research, I'm still confused about some features.

From what I so far understand, saving the TClientDataSet structure to a file, preserves only the FieldDefs. All other definitions such as filters and indexes are lost. So, I must recreate them after openning the DataSet, in order to that definitions take place.

I infere from this, that, if I want to store those definitions in disk (so they will available to the application as a whole and not only for a specific form), I must maintain a separate DataSet. Then, at runtime, I can recreate all definitions from that DataSet.

My question is: is there any other mechanism to store those definitions, other than the one mentioned above? A TDataSetProvider can do the trick?

I appologize for my ignorance and appreciate any enlightment about the subject.

Thanks in advance.

user2383818
  • 709
  • 1
  • 8
  • 19
  • That's the thing! I want to avoid the use of a database. It may sound a bit odd, but for my own reasons, I want that the application use `TClientDataSet` only. I think that `DataSet` has all the fetures my application may need. – user2383818 Feb 03 '14 at 15:33
  • There are many possibilities: 1- Regedit, 2-IniFiles, 3- Database, 4-Other DataSets. In this specific case I believe IniFiles is better – EProgrammerNotFound Feb 03 '14 at 15:33
  • @matheus. So a `TDataSetProvider` should not resolve, right? – user2383818 Feb 03 '14 at 15:35
  • DataSetProvider is often used to retrieve data from TQuery. – EProgrammerNotFound Feb 03 '14 at 15:36
  • @matheus. But it has the capability to store the `DataSet` definitions? – user2383818 Feb 03 '14 at 15:37
  • AFAIK. No, it doesn't has this capability. – EProgrammerNotFound Feb 03 '14 at 15:38
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/46689/discussion-between-user2383818-and-matheus-freitas) – user2383818 Feb 03 '14 at 15:41
  • @user2383818: why don´t you just use the ObjectInspector and set those definitions during design time? Indexes and filter will be saved in the DFM file and stored inside the .exe as a resource. When you instantiate the Form or DataModule where you droped the `TClientDataset`, those properties will be reloaded and the dataset will be ready. Then you just have to load the data. – AlexSC Feb 03 '14 at 16:28

2 Answers2

1

Yes, there are many possibilities to do what you want.

But, TDataSetProvider is not one of them.

It is possible to use:

  • 1 TRegistry
  • 2 TIniFiles
  • 3 Persist it in database (not a good approach)
  • 4 Another DataSet, as you mentioned.

Pick the easier and most realiable for you.
TIniFile is very often used to save definitions in many scenarios.

EProgrammerNotFound
  • 2,403
  • 4
  • 28
  • 59
0

When you save ClientDataSet it saves data structure, data, index definitions, parameters, delta-data etc. It saves only one filter definition though.

You can also save indesies and filters in Delphi code.

As mentioned Registry and IniFiles are possibilities too.