asp.net.ph

DataSet.HasChanges Method ( )

System.Data Namespace   DataSet Class


Checks whether the DataSet has changes, including new, deleted, or modified rows.

[ VB ]
Overloads Public Function HasChanges ( ) As Boolean

[ C# ]
public bool HasChanges ( );

[ C++ ]
public: bool HasChanges ( );

[ JScript ]
public function HasChanges ( ) : Boolean

Return Value

This method returns only a boolean value: true, if the DataSet has changes; otherwise, false.

The property is read only with no default value.

Remarks

Use the HasChanges method to determine if a DataSet contains new or edited data. If so, use the GetChanges method to create a new DataSet that contains only the changes.

Example

The following example uses the GetChanges method to create a second DataSet object that is then used to update a DBMS.

private void UpdateDataSet ( DataSet myDataSet ) {
   // check for changes with the HasChanges method first.
   if ( !myDataSet.HasChanges ( ) return;
   // create temporary DataSet variable.
   DataSet xDataSet;
   // getChanges for modified rows only.
   xDataSet = myDataSet.GetChanges ( DataRowState.Modified );
   // check the DataSet for errors.
   if ( xDataSet.HasErrors ) {
      // ... insert code to resolve errors here ...
  }
   // after fixing errors, update db with the DataAdapter used to fill the DataSet.
   myDataAdapter.Update ( xDataSet );
}
  C# VB

See Also

DataSet Members   DataSet.HasChanges Overload List   GetChanges   HasErrors Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph