| |
 |
How do I set up a single tier application using Client Datasets?
Currently, the only way to activate a client dataset at design time is to associate it with a provider, to load data from a file, or to assign data from another dataset. Typically, for a single tier application you would create the dataset at runtime using the CreateDataSet method. Here is how you might code the FormCreate and FormDestroy methods:
?
?OnFormCreate:?if FileExists('MYDATCDS') then
ClientDataSet.LoadFromFile('MYDATA.CDS')
else
begin
ClientDataSet.FieldDefs.Add('Field ', etc.);
ClientDataSet.FieldDefs.Add('Field2', etc.);
ClientDataSet.CreateDataset;
end; ?OnFormDestroy:? if ClientDataSet.Active then
begin
// Next line is optional,
// if you don't want undo support you could
// set LogChanges = False instead.
ClientDataSet.MergeChangeLog;
ClientDataSet.SaveToFile('MYDATA.CDS');
end;
?
Once you've run the app once and created the data file, you can easily load it at design time (from the right-click component menu) if you need to have the dataset active at design time for some reason.
|
|
| Hits/month |
2,500,000+ |
Downloads (Since May 2000) |
7,393,709 |
| Total Files |
6,023 |
| Forum msgs |
7,670 |
| Articles/FAQs |
70+/900+ |
Top Selling Software at Amazon
|