Does updating a dataset with the same value cause an underlying update?
Say I have a dataset, and I change a value in a datarow, but the value is identical to the old value:
开发者_如何学JAVAdataRow["someField"] = 2; // but it already had value 2!
Does this cause an update statement to be executed on the database, or does it recognize that nothing actually changed and perform no update?
Take a look at the DataRow.RowState property.
If the row was previously Unchanged,then setting the value will change the RowState to Modified.
You will need to manually check for equality before setting row values.
It will cause an update.
精彩评论