This documentation is archived and is not being maintained.

OracleDataAdapter.DeleteCommand Property

Gets or sets an SQL statement or stored procedure used to delete records in the database.

Namespace:  System.Data.OracleClient
Assembly:  System.Data.OracleClient (in System.Data.OracleClient.dll)

Public Property DeleteCommand As OracleCommand
Dim instance As OracleDataAdapter 
Dim value As OracleCommand 

value = instance.DeleteCommand

instance.DeleteCommand = value

Property Value

Type: System.Data.OracleClient.OracleCommand
An OracleCommand used during an update operation to delete records in the database that correspond to deleted rows in the DataSet.

When the DeleteCommand property is assigned to a previously created OracleCommand, the OracleCommand is not cloned. Instead, the DeleteCommand maintains a reference to the previously created OracleCommand.

During an update operation, if DeleteCommand is not set and primary key information is present in the DataSet, you can use the OracleCommandBuilder class to automatically generate the DeleteCommand, and additional commands needed to reconcile the DataSet to the database. To do this, set the SelectCommand property of the OracleDataAdapter. The generation logic also requires key column information to be present in the DataSet. For more information see Generating Commands with CommandBuilders (ADO.NET).

The following example creates an OracleDataAdapter and sets the SelectCommand and DeleteCommand properties. It assumes you have already created an OracleConnection object.

[Visual Basic]

Public Shared Function CreateCustomerAdapter(conn As OracleConnection) As OracleDataAdapter 
  Dim da As OracleDataAdapter = New OracleDataAdapter()
  Dim cmd As OracleCommand
  Dim parm As OracleParameter

  ' Create the SelectCommand.

  cmd = New OracleCommand("SELECT * FROM Dept " & _
                       "WHERE DName = :pDName AND Loc = :pLoc", conn)

  cmd.Parameters.Add("pDName", OracleType.NVarChar, 14)
  cmd.Parameters.Add("pLoc", OracleType.NVarChar, 13)

  da.SelectCommand = cmd

  ' Create the DeleteCommand.

  cmd = New OracleCommand("DELETE FROM Dept WHERE DeptNo = :pDeptNo", conn)

  parm = cmd.Parameters.Add("pDeptNo", OracleType.Number, 2, "DeptNo")
  parm.SourceVersion = DataRowVersion.Original

  da.DeleteCommand = cmd

  Return da
End Function


public static OracleDataAdapter CreateCustomerAdapter(OracleConnection conn)
  OracleDataAdapter da = new OracleDataAdapter();
  OracleCommand cmd;
  OracleParameter parm;

  // Create the SelectCommand.

  cmd = new OracleCommand("SELECT * FROM Dept " +
                       "WHERE DName = :pDName AND Loc = :pLoc", conn);

  cmd.Parameters.Add("pDName", OracleType.NVarChar, 14);
  cmd.Parameters.Add("pLoc", OracleType.NVarChar, 13);

  da.SelectCommand = cmd;

  // Create the DeleteCommand.

  cmd = new OracleCommand("DELETE FROM Dept WHERE DeptNo = :pDeptNo", conn);

  parm = cmd.Parameters.Add("pDeptNo", OracleType.Number, 2, "DeptNo");
  parm.SourceVersion = DataRowVersion.Original;

  da.DeleteCommand = cmd;

  return da;

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1