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 );
An OleDbCommand used during Update to update records in the data source that correspond to modified rows in the DataSet.
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.
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;
Dim myConn As New OleDbConnection ( _
"Provider=Microsoft.ACE.OLEDB.12.0; Data Source=gear.mdb" )
Dim query As String = "SELECT * FROM Products ORDER BY ProductID"
Dim myDataAdapter As 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 |
OleDbDataAdapter Members DeleteCommand InsertCommand SelectCommand