OleDbDataAdapter.SelectCommand 속성

정의

데이터 소스의 레코드를 선택하는 데 사용하는 SQL 문이나 저장 프로시저를 가져오거나 설정합니다.

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

속성 값

OleDbCommand에 있는 위치에 대한 데이터 소스에서 레코드를 선택하는 Fill(DataSet) 동안 사용하는 DataSet입니다.

특성

예제

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

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

설명

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

가 행을 SelectCommand 반환하지 않으면 에 테이블이 DataSet추가되지 않으며 예외가 발생하지 않습니다.

적용 대상

추가 정보