Is datatable.update necessary
-
Hi, This is closely related to my previous question BUT ... I go through a web log file and extract each line and put the data into a new row in a datatable. I then change the data in one field of each row. I then use that datatable as my source for extracting various statistics. At no time do I really need to save the datatable to the underlying database as far as I can see. If I don't need to save the datatable to the database, do I really need to do a datatable.update let alone a dataset.acceptchanges?
Glen Harvy
-
Hi, This is closely related to my previous question BUT ... I go through a web log file and extract each line and put the data into a new row in a datatable. I then change the data in one field of each row. I then use that datatable as my source for extracting various statistics. At no time do I really need to save the datatable to the underlying database as far as I can see. If I don't need to save the datatable to the database, do I really need to do a datatable.update let alone a dataset.acceptchanges?
Glen Harvy
-
If you only need to use the DataTable object as an in-memory repository for data, then you don't need to use these methods. They are used for synchronising the contents of the DataTable with an underlying database. Paul
Thanks for that - it's funny how I have never stopped to think about what I was doing until performance became an issue. Suppose this is often the case now that I think about it. Just one thing more though... Is there any need at all to call dataset.acceptchanges() if you have just done a datatable.update and you know there hasn't been any other changes to the datatset. Logically the answer is no but I just want to confirm that. Thanks for your time.
Glen Harvy
-
Thanks for that - it's funny how I have never stopped to think about what I was doing until performance became an issue. Suppose this is often the case now that I think about it. Just one thing more though... Is there any need at all to call dataset.acceptchanges() if you have just done a datatable.update and you know there hasn't been any other changes to the datatset. Logically the answer is no but I just want to confirm that. Thanks for your time.
Glen Harvy
I don't do this kind of stuff with DataTables very often, but according to the MSDN documentation... When AcceptChanges is called, any DataRow object still in edit mode successfully ends its edits. The DataRowState also changes: all Added and Modified rows become Unchanged, and Deleted rows are removed. So I think you should call AcceptChanges after Update to reset the status of the rows in your DataTable. Paul
-
I don't do this kind of stuff with DataTables very often, but according to the MSDN documentation... When AcceptChanges is called, any DataRow object still in edit mode successfully ends its edits. The DataRowState also changes: all Added and Modified rows become Unchanged, and Deleted rows are removed. So I think you should call AcceptChanges after Update to reset the status of the rows in your DataTable. Paul
Yep - I agree with you. Thanks.
Glen Harvy