property ServerDataSet: string;
ASTA supports the use of datasets on the ASTA server also. The property ServerDataSet pulls down a list of any TDataSet descendents in use on the connected ASTA server. If you are not sure as to which type any of these datasets are, you can get more detailed information from the SQLWorkbench tab ServerDataSets. This shows not only the list of the TDataSets on the server but their Delphi 'type' also. A TQuery or a TTable or a TAstaDataSet are examples of possible values. This would include any TDataSet descendent that you use for your particular backend, like InfoPower TwwQueries or ODBCExpress TOEDataSets.
The ASTAClientDataSet can act as mirror of any of these datasets sitting on the ASTA server. Set the ServerDataSet property to the TDataSet descendent that you want to fetch data from and then set the MetaDataRequest property to TACustomDataSets. Note: design time population of ServerDataSets is not supported at this time. To populate the TAstaClientDataSet with the data contained in the specified server side TDataSet, just set the active property to True anytime after the TAstaClientSocket connects to the server. The earliest you may do this, is in the TAstaClientSocketís OnConnect event.
When using the ASTA server side features as described above there are additional options available that are not available when writing your own client side SQL.
∑ The actual FieldDef properties from the ServerDataSet is streamed to the TAstaclientDataSet so that in the DoAfterOpen routine of the TAstaClientDataSet, all of the actual field properties, as set on the server are mirrored on the client. This includes such properties as DisplayLabel, DisplayWidth, Edit Masks, Alignment, ReadOnly, DisplayFormat, etc.There is slight additional overhead for this as all the FieldDef properties are streamed from the server to the client.
∑ You have the opportunity to trigger a ServerActionEvent and to pass values to the ServerDataSet along with an Action Identifier. This will allow you to make decisions on the server according to client requests.
To trigger a server side event for a specific dataset on the server, you must write two events, one on the client and one on the server.
The TAstaClientDataSet needs to have itís OnCustomServerActionEvent coded. The following example is from the tutorial found in the \Asta\Tutorials\ServerDataSet directory. The AstaClientDataSet in this example, is mirroring the UserDataSet on the ASTA server. The UserDataSet is an in-memory TAstaDataSet that contains a history of connect information that you can view from the Connected Users tab on the example ASTA servers. This event will force the UserDataSet to go to the first record and update the Activity field with the current date and time.
procedure TForm1.AstaClientDataSet1CustomServerAction(Sender: TObject;
var ActionInt: Integer);
ActionInt := 17;
//Params must be populated here.They will be set to 0 count before this call
with AstaClientDataSet1 do begin
Params.FastAdd('Asta Server Action!');
The above example sends an ActionInt integer value to the server so that the server can trigger an event. By adding values to the Params property using the FastAdd method, typed parameters can be sent to the server. In this example, a String, an Integer, a Double and a TDateTime are sent to the server.
The following code is taken from the BDEServer example code found in the \ASta\Servers\BDE\Code directory and is the actual code running on the BDE and ODBC servers as supplied with the ASTA components.
procedure TForm1.AstaServerSocket1ServerDataSetAction(Sender: TObject;
DS: TDataSet; ActionID: Integer; ClientParams: TAstaParamList);
//this shows an example of a server side dataset that is being
//streamed back to a client
//You can check to see which dataset is being streamed and
//take appropriate action based on the ActionID.
//You also have incoming Params from the client if you want
//to do something with them.
if (DS = UserDataSet) and (Actionid = 17) and
'Client Action! at ' + DateTimeToStr(Now);
The TAstaServerSocket has an OnServerDataSetAction event where you can compare the dataset coming in with the client request, process the ActionID coming in as an integer to key off of for any action you want to take, and also receive typed parameters coming from the client. You may want to close and open the dataset, change the Order By or Where clause or take any other kind of action. The parameters come in as a TAstaParamList so you may use them as any kind of data type that you need. In the above example, the incoming parameters are appended to the client requests memo on the server.
With this kind of server and client communication, ASTA gives you the best of client side AND server side development options. You decide how to write your 3-Tier application and ASTA supports any model that you want to use.