asp.net.ph

OleDbDataAdapter.DeleteCommand Property

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 );

Property Value

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

Remarks

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.

Example

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;
  C# VB

See Also

OleDbDataAdapter Members   InsertCommand   SelectCommand   UpdateCommand 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