Reusable Function to Update a Datasource from a Disconnected Dataset

One of the great things about ADO.Net is the ability to work with disconnected datasets. However, you may frequently find yourself writing some code to update your datasource for individual updates (

ITPro Today

March 24, 2002

1 Min Read
ITPro Today logo in a gray background | ITPro Today

One of the great things about ADO.Net is the ability to work with disconnected datasets. However, you may frequently find yourself writing some code to update your datasource for individual updates (whether you are using a SQL database or an Ole DB source). Here is a quick, reusable function that allows you to pass an updated dataset, and it will access the dataAdapter and update your changes. Rather than making updates directly to the datasource, particularly large batch updates, fill a dataset from your dataAdapter. Insert, delete, and update to this dataset and call this function after to commit the changes. This can also eliminate the need for simpler transactions to SQL by using the disconnected dataset and updating all at once. This function works great in a data tier component class and can easily be adapted to use OleDbDataAdapter.

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like