Skip navigation

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 (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.

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish