ASTA supports a Suitcase or persistant model in that any TAstaClientDataSet can :
∑ Save and load itself from a stream
∑ Save and load itself from a file
∑ Save and load itself form a blob field (since it can stream itself)
∑ Sort itself on any column (except blob fields) or multiple columns
∑ Use itís built in filter to simlulate indexes
The following discussion uses the example as supplied with the ASTA components in the \ASTA\Tutorials\SuitCase directory.
The TAstaClientDataSet has a property called SuitCaseData that expands to sub properties
∑ Active This determines whether the TAstaClientDataSet will fetch data from a local disk or connect to an ASTA server for itís data.
∑ FileName This is a name to be used by the TAstaClientDataSet to stream and load itself from disk.
∑ SaveCachedUpdates This also saves and loads the internal FOldValuesDataSet where ASTA stores the original values if EditMode is set to Cached or After Post.
In the Asta Suitcase tutorial, a normal query is run but then the TAstaClientDataSet saves the data from the query to a file by calling AstaClientDataSet1.SaveSuitCaseData. This saves all the data, including all the field types (even blobs and memo fields) to disk. Run the tutorial, do the query and click the Save to File button. Stop the tutorial, and this time set the SuitCaseData.Active property to True. When you compile and run the tutorial, instead of fetching the data from the remote ASTAServer, the TAstaClientDataSet will load the data from the SuiteCaseData.FileName property.
The following methods are available to aid in the Suitcase Model and are implemented in the TAstaDataSet the ancestor of the TAstaClientDataSet.
Power User Tip:
Sometimes when you want to use a DBGrid component on a form connected to a TAstaDataSet you want the grid to show the field names as column headers even when the TAstaDataSet has not fetched any data. Follow these steps:
1. Set up a normal query with some SQL and set the Active property to True.
2. Set the Suitcase.Active to True but DO NOT put a file name in the Suitcase.Filename property. This will have the effect of keeping the table open at run time but NOT firing a query to fetch data from the server. This is what OpenNoFetch does.
3. When you want to fetch your data, instead of closing and opening the table, call the AstaClientDataSet.RefireSQL method.