asp.net.ph

OleDbDataAdapter.UpdateCommand Property

System.Data.OleDb Namespace   OleDbDataAdapter Class


Returns or sets an SQL statement used to update records in the data source.

[ VB ]
Public Property UpdateCommand As OleDbCommand

[ C# ]
public OleDbCommand UpdateCommand {get; set;}

[ C++ ]
public: __property OleDbCommand* get_UpdateCommand ( );
public: __property void set_UpdateCommand ( OleDbCommand* );

[ C++ ]
public function get UpdateCommand ( ) : OleDbCommand;
public function set UpdateCommand ( OleDbCommand );

Property Value

An OleDbCommand used during Update to update records in the data source that correspond to modified rows in the DataSet.

Remarks

During Update, if this property is not set and primary key information is present in the DataSet, the UpdateCommand can be generated automatically if you set the SelectCommand property and use the OleDbCommandBuilder. Then, any additional commands that you do not set are generated by the OleDbCommandBuilder. This generation logic requires key column information to be present in the DataSet. For more information see Automatically Generated Commands.

When UpdateCommand is assigned to a previously created OleDbCommand, the OleDbCommand is not cloned. The UpdateCommand maintains a reference to the previously created OleDbCommand object.

NOTE: If execution of this command returns rows, these rows may be merged with the DataSet depending on how you set the UpdatedRowSource property of the OleDbCommand object.

Example

The following example initializes an OleDbDataAdapter and sets some of its properties.

OleDbConnection myConn = new OleDbConnection (
   "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=gear.mdb" );
string query = "SELECT * FROM Products ORDER BY ProductID";

OleDbDataAdapter myDataAdapter = new OleDbDataAdapter ( query, myConn );
myDataAdapter.UpdateCommand.CommandText = 
   "UPDATE Products SET Description='Cheeses, Milk, Ice Cream' " +
   "WHERE CategoryName='Dairy Products'";
myDataAdapter.UpdateCommand.Connection = 
   myDataAdapter.SelectCommand.Connection;
  C# VB

See Also

OleDbDataAdapter Members   DeleteCommand   InsertCommand   SelectCommand Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph