Submit all changes made to the table since the last acceptchanges call.
Call acceptchanges and use dataadapter. Update ()No matter what new data is updated to the database. That ...... So what is its usefulness?
Previous practices:
Fill-> edit-> Update-> another fill-> edit-> Update-> ......
"Of course we have to retrieve the updated data again !", After the update is performed again, it is obtained again.
Today's practices:
Fill-> edit-> Update-> acceptchanges-> edit-> Update-> ......
You can get the data one time at the beginning. Isn't it what you just updated after updating the data? Why do you need to get it again?
Acceptchanges after update!
----------------------------------------- Ugly cutting line -------------------------------------------------------------
Acceptchanges () and rejectchanges () http://www.cnblogs.com/perfect/archive/2007/08/06/844634.html
I recently read several related articles in the garden and summarized them (please correct them more ):
Delete () is an object-oriented State operation (rollback is allowed); removeat () is a common set operation (rollback is not allowed, and is equivalent to delete () post acceptchanges ())
Datatable. acceptchanges Method
Submit all changes made to the table since the last acceptchanges call. When you call acceptchanges, the editing of any datarow object that is still in editing mode is completed successfully. The datarowstate is also changed: the status of all rows in the "added" or "modified" state is changed to "unchanged", and rows in the "deleted" state are removed.
After you try to update the dataset using the dbdataadapter. Update method, the acceptchanges method is generally called for the datatable. Datatable. rejectchanges Method
Roll back all changes made to the table since the table is loaded or since the last acceptchanges call.
When rejectchanges is called, any datarow object that is still in edit mode will be unedited. The new row is removed. The row whose datarowstate is set to modified or deleted is returned to its initial state. After the delete method is used, rowstate becomes "deleted ". It remains "deleted" until you call acceptchanges ". You can call rejectchanges to cancel row deletion. Removeat indicates that all data in the row will be lost when the row is removed. You can also call the delete method of the datarow class to mark a row for removal. Calling removeat is equivalent to calling Delete before calling acceptchanges. That is to say, the row can be rolled back after being deleted using the delete () method, but the removeat (INT) method cannot be used. Summary:
1. After the acceptchanges () is received before the delete () operation, only the delete mark is added. After the acceptchanges () operation is accepted again, the operation is deleted. Otherwise, the acceptchanges () operation is not accepted again () rollback upon rejectchanges ()
2. The acceptchanges () is not received before the delete () operation, and then the acceptchanges () operation is accepted immediately.
3. If you do not receive acceptchanges () before the delete () operation and do not immediately accept acceptchanges () operation, it will be permanently deleted: because there is no need to roll back