Прочетете на английски Редактиране

Споделяне чрез


OracleDataAdapter.SelectCommand Property

Definition

Gets or sets an SQL statement or stored procedure used to select records in the database.

C#
public System.Data.OracleClient.OracleCommand SelectCommand { get; set; }

Property Value

An OracleCommand that is used during a fill operation to select records from database for placement in the DataSet.

Examples

The following example creates an OracleDataAdapter and sets the SelectCommand and InsertCommand properties. It assumes you have already created an OracleConnection object.

C#
public static OracleDataAdapter CreateCustomerAdapter(OracleConnection conn)  
{  
  OracleDataAdapter da = new OracleDataAdapter();  
  OracleCommand cmd;  

  // Create the SelectCommand.  

  cmd = new OracleCommand("SELECT * FROM Dept " +  
                       "WHERE DName = :pDName AND Loc = :pLoc", conn);  

  cmd.Parameters.Add("pDName", OracleType.NVarChar, 14);  
  cmd.Parameters.Add("pLoc", OracleType.NVarChar, 13);  

  da.SelectCommand = cmd;  

  // Create the InsertCommand.  

  cmd = new OracleCommand("INSERT INTO Dept (DeptNo, DName) " +  
                       "VALUES (:pDeptNo, :pDName)", conn);  

  cmd.Parameters.Add("pDeptNo", OracleType.Number, 2, "DeptNo");  
  cmd.Parameters.Add("pDName", OracleType.NVarChar, 14, "DName");  

  da.InsertCommand = cmd;  

  return da;  
}  

Remarks

When SelectCommand is assigned to a previously created OracleCommand, the OracleCommand is not cloned. Instead, the SelectCommand maintains a reference to the previously created OracleCommand object.

If SelectCommand does not return any rows, no tables are added to the DataSet, and no exception is raised.

Applies to

Продукт Версии
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

See also