OleDbDataAdapter.DeleteCommand 속성

정의

데이터 집합에서 레코드를 삭제하는 SQL 문이나 저장 프로시저를 가져오거나 설정합니다.

public:
 property System::Data::OleDb::OleDbCommand ^ DeleteCommand { System::Data::OleDb::OleDbCommand ^ get(); void set(System::Data::OleDb::OleDbCommand ^ value); };
public System.Data.OleDb.OleDbCommand DeleteCommand { get; set; }
public System.Data.OleDb.OleDbCommand? DeleteCommand { get; set; }
[System.Data.DataSysDescription("DbDataAdapter_DeleteCommand")]
public System.Data.OleDb.OleDbCommand DeleteCommand { get; set; }
member this.DeleteCommand : System.Data.OleDb.OleDbCommand with get, set
[<System.Data.DataSysDescription("DbDataAdapter_DeleteCommand")>]
member this.DeleteCommand : System.Data.OleDb.OleDbCommand with get, set
Public Property DeleteCommand As OleDbCommand

속성 값

OleDbCommand의 삭제된 행에 해당하는 데이터 소스의 레코드를 삭제하는 Update(DataSet) 동안 사용된 DataSet입니다.

특성

예제

다음 예제에서는 를 만들고 OleDbDataAdapterDeleteCommand 속성을 설정합니다SelectCommand. 개체를 이미 만들었다고 OleDbConnection 가정합니다.

public static OleDbDataAdapter CreateCustomerAdapter(
    OleDbConnection connection)
{
    OleDbDataAdapter dataAdapter = new OleDbDataAdapter();
    OleDbCommand command;
    OleDbParameter parameter;

    // Create the SelectCommand.
    command = new OleDbCommand("SELECT CustomerID FROM Customers " +
        "WHERE Country = ? AND City = ?", connection);

    command.Parameters.Add("Country", OleDbType.VarChar, 15);
    command.Parameters.Add("City", OleDbType.VarChar, 15);

    dataAdapter.SelectCommand = command;

    // Create the DeleteCommand.
    command = new OleDbCommand(
        "DELETE * FROM Customers WHERE CustomerID = ?",
        connection);

    parameter = command.Parameters.Add(
        "CustomerID", OleDbType.Char, 5, "CustomerID");
    parameter.SourceVersion = DataRowVersion.Original;

    dataAdapter.DeleteCommand = command;

    return dataAdapter;
}
Public Shared Function CreateCustomerAdapter( _
    connection As OleDbConnection) As OleDbDataAdapter 

    Dim dataAdapter As New OleDbDataAdapter()
    Dim command As OleDbCommand
    Dim parameter As OleDbParameter

    ' Create the SelectCommand.
    command = New OleDbCommand("SELECT CustomerID FROM Customers " & _
        "WHERE Country = ? AND City = ?", connection)

    command.Parameters.Add("Country", OleDbType.VarChar, 15)
    command.Parameters.Add("City", OleDbType.VarChar, 15)

    dataAdapter.SelectCommand = command

    ' Create the DeleteCommand.
    command = New OleDbCommand( _
        "DELETE * FROM Customers WHERE CustomerID = ?", _
        connection)

    parameter = command.Parameters.Add( _
        "CustomerID", OleDbType.Char, 5, "CustomerID")
    parameter.SourceVersion = DataRowVersion.Original

    dataAdapter.DeleteCommand = command

    Return dataAdapter
End Function

설명

중에 Update이 속성이 설정되지 않고 기본 키 정보가 에 DataSetDeleteCommand 있는 경우 속성을 설정하고 SelectCommand 를 사용하면 OleDbCommandBuilder가 자동으로 생성될 수 있습니다. 그런 다음, 설정하지 않은 추가 명령은 에 의해 OleDbCommandBuilder생성됩니다. 이 세대 논리에 키 열 정보가 필요 합니다 DataSet합니다. 자세한 내용은 CommandBuilder를 사용하여 명령 생성을 참조하세요.

DeleteCommand 가 이전에 만든 OleDbCommand에 할당되면 가 OleDbCommand 복제되지 않습니다. 는 DeleteCommand 이전에 만든 OleDbCommand 개체에 대한 참조를 유지 관리합니다.

적용 대상

추가 정보