OracleDataAdapter.SelectCommand OracleDataAdapter.SelectCommand OracleDataAdapter.SelectCommand OracleDataAdapter.SelectCommand Property

Definizione

Ottiene o imposta un'istruzione SQL o una stored procedure utilizzata per selezionare record nel database.Gets or sets an SQL statement or stored procedure used to select records in the database.

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

Valore della proprietà

Oggetto OracleCommand utilizzato durante un'operazione di riempimento per selezionare record dal database e collocarli nell'oggetto DataSet.An OracleCommand that is used during a fill operation to select records from database for placement in the DataSet.

Esempi

L'esempio seguente crea un OracleDataAdapter e imposta la SelectCommand e InsertCommand proprietà.The following example creates an OracleDataAdapter and sets the SelectCommand and InsertCommand properties. Si presuppone di aver già creato un OracleConnection oggetto.It assumes you have already created an OracleConnection object.

Public Shared Function CreateCustomerAdapter(conn As OracleConnection) As OracleDataAdapter   

  Dim da As OracleDataAdapter = New OracleDataAdapter()  
  Dim cmd As OracleCommand  

  ' 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  
End Function  
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;  
}  

Commenti

Quando SelectCommand viene assegnato a un oggetto creato in precedenza OracleCommand, il OracleCommand non viene clonato.When SelectCommand is assigned to a previously created OracleCommand, the OracleCommand is not cloned. Al contrario, il SelectCommand mantiene un riferimento all'oggetto creato in precedenza OracleCommand oggetto.Instead, the SelectCommand maintains a reference to the previously created OracleCommand object.

Se SelectCommand non restituisce alcuna riga, alcun tabelle non vengono aggiunte per il set di dati, e viene generata alcuna eccezione.If SelectCommand does not return any rows, no tables are added to the DataSet, and no exception is raised.

Si applica a

Vedi anche