System.Data.OleDb Namespace OleDbDataAdapter Class
Sets or retrieves an SQL statement for deleting records from the data set.
[ VB ]
Public Property DeleteCommand As OleDbCommand
[ C# ]
public OleDbCommand DeleteCommand {get; set;}
[ C++ ]
public: __property OleDbCommand* get_DeleteCommand ( );
public: __property void set_DeleteCommand ( OleDbCommand* );
[ C++ ]
public function get DeleteCommand ( ) : OleDbCommand;
public function set DeleteCommand ( OleDbCommand );
An OleDbCommand used during Update to delete records in the data source that correspond to deleted rows in the DataSet.
During Update, if this property is not set and primary key information is present in the DataSet, the DeleteCommand 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 DeleteCommand is assigned to a previously created OleDbCommand, the OleDbCommand is not cloned. The DeleteCommand maintains a reference to the previously created OleDbCommand object.
The following example initializes an OleDbDataAdapter and sets some of its properties.
string myConn = "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.DeleteCommand.CommandText =
"DELETE FROM Products WHERE CategoryName='Climbing'";
myDataAdapter.DeleteCommand.Connection =
myDataAdapter.SelectCommand.Connection;
Dim myConn As String = "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.DeleteCommand.CommandText = _
"DELETE FROM Products WHERE CategoryName='Climbing'"
myDataAdapter.DeleteCommand.Connection = _
myDataAdapter.SelectCommand.Connection
|
|
C# |
VB |
OleDbDataAdapter Members InsertCommand SelectCommand UpdateCommand