다음을 통해 공유


DbDataAdapter.SelectCommand 속성

정의

데이터 소스에서 레코드를 선택하는 데 사용되는 명령을 가져오거나 설정합니다.

public:
 property System::Data::Common::DbCommand ^ SelectCommand { System::Data::Common::DbCommand ^ get(); void set(System::Data::Common::DbCommand ^ value); };
[System.ComponentModel.Browsable(false)]
public System.Data.Common.DbCommand? SelectCommand { get; set; }
[System.ComponentModel.Browsable(false)]
public System.Data.Common.DbCommand SelectCommand { get; set; }
[<System.ComponentModel.Browsable(false)>]
member this.SelectCommand : System.Data.Common.DbCommand with get, set
Public Property SelectCommand As DbCommand

속성 값

IDbCommand를 수행하는 동안 데이터 집합에 배치할 레코드를 데이터 소스에서 선택하는 데 사용되는 Update(DataSet)입니다.

특성

예제

다음 예제에서는 파생 클래스 OleDbDataAdapter 를 만들고 해당 속성 중 일부를 설정합니다.

public static OleDbDataAdapter CreateCustomerAdapter(
    OleDbConnection connection)
{
    OleDbDataAdapter adapter = new OleDbDataAdapter();
    OleDbCommand command;

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

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

    adapter.SelectCommand = command;

    // Create the InsertCommand.
    command = new OleDbCommand(
        "INSERT INTO Customers (CustomerID, CompanyName) " +
        "VALUES (?, ?)", connection);

    command.Parameters.Add(
        "CustomerID", OleDbType.Char, 5, "CustomerID");
    command.Parameters.Add(
        "CompanyName", OleDbType.VarChar, 40, "CompanyName");

    adapter.InsertCommand = command;
    return adapter;
}
Public Shared Function CreateCustomerAdapter( _
    connection As OleDbConnection) As OleDbDataAdapter 

    Dim adapter As New OleDbDataAdapter()
    Dim command As OleDbCommand

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

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

    adapter.SelectCommand = command

    ' Create the InsertCommand.
    command = New OleDbCommand( _
        "INSERT INTO Customers (CustomerID, CompanyName) " & _
        "VALUES (?, ?)", connection)

    command.Parameters.Add( _
        "CustomerID", OleDbType.Char, 5, "CustomerID")
    command.Parameters.Add( _
        "CompanyName", OleDbType.VarChar, 40, "CompanyName")

    adapter.InsertCommand = command
    Return adapter
End Function

적용 대상

추가 정보