If you have a PH account, you can customize your PH profile.
*/
*/

ADONET FAQ - Updating Tables in the Dataset

How do I update tables in the dataset?

Updating a table in ADO.Net is very interesting and easy. You need to follow these steps to update, insert and delete records:
  • The Data Adapter class (SqlDataAdapter) has properties for each of the insert, update and delete commands. First of all we need to prepare the command (SqlCommand) and add it to the data adapter object. The commands are simple SQL commands with parameters. You may use the Visual Studio .Net designer to easily create these commands.
  • Secondly we need to add parameters to these commands. The parameters are simply the names of the data table fields involved in the particular command. Visual Studio .Net also build it for you in its Data Adapter configuration wizard.
  • The two steps described above are done only once in the application. For each insert, update and delete; we insert, update and delete the corresponding data row (DataRow) of the data table (DataTable) object.
  • After any update we call the Update() method of the data adapter class by supplying to it, the dataset and table name as parameters. This updates our local dataset.
  • Finally we call the AcceptChanges() method of the dataset object to store the changes in the dataset to the physical database.
Back
corner
© 1996-2008 CommunityHeaven LLC. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
North American business development: Nicolai Wadstrom. Publisher: Lars Hagelin.
Resource Listings