OleDbDataAdapter.SelectCommand 속성
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
데이터 원본에서 레코드를 선택하는 데 사용되는 SQL 문 또는 저장 프로시저를 가져오거나 설정합니다.
public:
property System::Data::OleDb::OleDbCommand ^ SelectCommand { System::Data::OleDb::OleDbCommand ^ get(); void set(System::Data::OleDb::OleDbCommand ^ value); };
[System.Data.DataSysDescription("DbDataAdapter_SelectCommand")]
public System.Data.OleDb.OleDbCommand SelectCommand { get; set; }
public System.Data.OleDb.OleDbCommand SelectCommand { get; set; }
[<System.Data.DataSysDescription("DbDataAdapter_SelectCommand")>]
member this.SelectCommand : System.Data.OleDb.OleDbCommand with get, set
member this.SelectCommand : System.Data.OleDb.OleDbCommand with get, set
Public Property SelectCommand As OleDbCommand
속성 값
OleDbCommand 에 배치DataSet할 데이터 원본에서 레코드를 선택하는 데 Fill(DataSet) 사용되는 값입니다.
- 특성
예제
다음 예제에서는 및 OleDbDataAdapter 속성을 만들고 설정합니다 SelectCommandInsertCommand . 개체를 이미 만들었다고 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
설명
이전에 만든 SelectCommandOleDbCommand 데이터베이스에 할당된 경우 OleDbCommand 복제되지 않습니다. 이전에 SelectCommand 만든 OleDbCommand 개체에 대한 참조를 유지 관리합니다.
반환되는 행이 SelectCommand 없으면 테이블에 테이블이 추가 DataSet되지 않으며 예외가 발생하지 않습니다.