top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Explain DataSet.AcceptChanges and DataAdapter.Update methods in .NET?

0 votes
626 views
Explain DataSet.AcceptChanges and DataAdapter.Update methods in .NET?
posted Dec 16, 2015 by Jayshree

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

DataAdapter.Update method Calls the respective INSERT, UPDATE, or DELETE statements for each inserted, updated, or deleted row in the DataSet.
DataSet.AcceptChanges method Commits all the changes made to this row since the last time AcceptChanges was called.

Dataset maintains the rowstate of each row with in a table. as a dataset is loaded its rowstate version is unchanged . whenever there is a modification in a paricular row with in a datatable , dataset changes the rowversion as modified, Added or deleted based on the particular action performed on the particular row.
AcceptChanges() method again change the Rowversion back to Unchanged.

Update() method is for updation of any changes made to the dataset in the database. This function checks the rowversion of each row with in a table. If it finds any row with added rowstate then that particular row is inserted else if it is Modified it is upadted if deleted then a delete statement is executed.
But if Acceptchanges() is done before an update function it wold not update anything to database since rowstate becomes unchanged

answer Dec 16, 2015 by Shivaranjini
...