NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

General steps for using a DataSet With Existing Data

These are the general steps to use a DataSet with existing data:

  1. Build and fill each table in a DataSet with data from a DBMS using a SQLDataSetCommand or ADODataSetCommand. See Creating a Simple DataSetCommand
  2. Change the data in individual DataTable objects by adding, updating, or deleting DataRow objects. See ...
  3. Invoke the GetChanges method to create a second DataSet that features only the changes to the data. The method requires one argument, the DataRowState of the changes you are interested in. The example below uses the method to return a DataSet with only the modified rows:
    [VB]
    Dim changedDataSet As DataSet
    changedDataSet = ds.GetChanges(DataRowState.Modified)
    [C#]
    System.Data.DataSet changedDataSet;
    changedDataSet = ds.GetChanges(DataRowState.Modified);
  4. Check for errors in the second DataSet by examining its HasErrors property, which informs you if any table in the set has errors. See section…
  5. If errors are present, check the HasErrors property of each DataTable . If the table has errors, invoke the DataTable class's GetErrors method to return an array of DataRow objects with errors.
  6. On each DataRow examine the RowError property for specific data.
  7. Reconcile the errors, if possible.
  8. Invoke the Merge method to merge the changes from the second DataSet into the first.
    [VB]
    ds.Merge(changedDataSet)
    [C#]
    ds.Merge(changedDataSet);
  9. Call the Update method of the SQLDataSetCommand (or ADODataSetCommand), passing the merged DataSet as an argument.
    [VB]
    workDSCMD.Update(ds)
    [C#]
    workDSCMD.Update(ds);
  10. Invoke the AcceptChanges on the DataSet. Alternatively, invoke RejectChanges to cancel the changes.
    ds.AcceptChanges