7 Designing .NET Applications for Performance Optimization : Updating Data

Updating Data
This section provides general guidelines to help you optimize system performance when updating data in databases.
Synchronizing Changes Back to the Data Source
The following example shows the application flow for updating a DataSet using Oracle’s Rowid as the update mechanism:
// Create the DataAdapter and DataSets
OracleCommand DbCmd = new OracleCommand
("SELECT rowid, deptid, deptname FROM department", DBConn);
 
myDataAdapter = new OracleDataAdapter();
myDataAdapter.SelectCommand = DBCmd;
myDataAdapter.Fill(myDataSet, "Departments");
 
// Build the Update rules
// Specify how to update data in the data set
myDataAdapter.UpdateCommand = new
OracleCommand("UPDATE department SET deptname = ? ", deptid = ? " +
   "WHERE rowid =?", DBConn);
 
// Bind parameters
myDataAdapter.UpdateCommand.Parameters.Add
   ("param1", OracleDbType.VarChar,100,"deptname");
myDataAdapter.UpdateCommand.Parameters.Add("param2",
   OracleDbType.Number,4,"deptid";
myDataAdapter.UpdateCommand.Parameters.Add("param3",
   OracleDbType.Number,4,"rowid");
In this example, performance of the queries on the Oracle server improves because the Where clause includes only the rowid as a search condition.