Try OpenEdge Now
skip to main content
.NET Open Clients
Passing Parameters : Passing DATASET and DATASET-HANDLE parameters : Updating a DataSet

Updating a DataSet

DataSets are useful for passing updated data between a client and server. Typically, the client obtains the DataSet from the AppServer, makes changes to the DataSet, and sends those changes back to the AppServer. The AppServer matches the records back to the original datasource, verifies that the records were not changed by other users, and then applies the changes to the datasource. The server passes back the final versions of records that may have been further changed on the server, along with any errors.
DataSets in both .NET and ABL have built-in support for updating. In addition to being an in-memory cache of data, DataSets keep track of which records were changed (modified, added, or deleted). They also keep track of the original or before-image versions of modified or deleted records, so the server can compare those records against the current records in the datasource. (ProDataSets on the AppServer need to define a before table to keep track of original values.)
The normal processing of DataSets for update is as follows:
1. Get an original DataSet to the client, normally using an OUPUT parameter.
2. Make changes to the DataSet on the client.
3. When you are ready to send updates to the server, call the GetChanges method on the System.Data.DataSet class. This returns you a new System.Data.DataSet with only the changed (modified, added, or deleted) records, including the original versions of the modified and deleted records. This is the DataSet that should be sent back to the AppServer for update, since there is no reason to send back any records that did not change.
Note: You may find it best to send updates to the AppServer whenever a single set of related records are updated, for example, a Customer record and all associated orders. Packaging updates simplifies the reconciliation process back from the AppServer to the original DataSet on the client.
4. Send the changes-only DataSet from Step 3 to the AppServer. Typically, this DataSet is sent as an INPUT-OUTPUT parameter, so the results from the AppServer's DataSet update can be passed back to the client.
5. Process the return from the AppServer. On output, the DataSet contains the changes-only DataSet, including any further updated records or errors from the AppServer. Note that only updates to the current set of changed records are included, not updates by other users to records not in the current set.
6. Match each row in the changes-only DataSet back to the row in the original DataSet, and refresh the client DataSet as necessary. Once the refresh is complete, call the AcceptChanges( ) method on your DataSet. Your DataSet is now ready for more changes, as in Step 2.