Главная страница | назад





Article #15504: Single Tier Applications

 Question and Answer Database
FAQ504D.txt Single Tier Applications
Category :DCOM/MultiTier/ActiveForm
Platform :All
Product :Delphi 3.x
Question:
How do I set up a single tier application using Client
Datasets?
Answer:
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('MYDATA.CDS') then ClientDataSet.LoadFromFile('MYDATA.CDS') else begin ClientDataSet.FieldDefs.Add('Field1', 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. 7/16/98 4:31:28 PM

Last Modified: 01-SEP-99