ADO.net Updating Data

Go back to: Code Samples
// 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”);




Like what you see? Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • LinkedIn
  • Reddit
  • StumbleUpon
  • Technorati
  • TwitThis

Book Content Copyright © 2009 by Prentice Hall PTR. All rights reserved. | Corporate Sponsor DataDirect Technologies.