IDbDataAdapter.DeleteCommand 속성

정의

데이터 집합에서 레코드를 삭제하기 위한 SQL 문을 가져오거나 설정합니다.

public:
 property System::Data::IDbCommand ^ DeleteCommand { System::Data::IDbCommand ^ get(); void set(System::Data::IDbCommand ^ value); };
public System.Data.IDbCommand DeleteCommand { get; set; }
member this.DeleteCommand : System.Data.IDbCommand with get, set
Public Property DeleteCommand As IDbCommand

속성 값

IDbCommand 데이터 집합에서 삭제된 행에 대한 데이터 원본의 레코드를 삭제하는 동안 Update(DataSet) 사용되는 값입니다.

예제

다음 예제에서는 상속된 OleDbDataAdapter 클래스의 인스턴스를 만들고 및 SelectCommand 속성을 설정합니다DeleteCommand. 개체를 이미 만들었다고 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

설명

이 속성이 설정되지 않고 기본 키 정보가 있는 UpdateDataSet 경우 DeleteCommand.NET Framework 데이터 공급자의 속성을 설정 SelectCommand 하면 자동으로 생성될 수 있습니다. 그런 다음, 설정하지 않은 추가 명령은 CommandBuilder에 의해 생성됩니다. 이 생성 논리에는 키 열 정보가 DataSet있어야 합니다. 자세한 내용은 CommandBuilders를 사용하여 명령 생성을 참조하세요.

이전에 만든 DeleteCommandIDbCommand 데이터베이스에 할당된 경우 IDbCommand 복제되지 않습니다. 이전에 DeleteCommand 만든 IDbCommand 개체에 대한 참조를 유지 관리합니다.

적용 대상