OracleCommand.Connection Property

Definition

Gets or sets the OracleConnection used by this instance of the OracleCommand.

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

Property Value

The connection to a data source. The default is a null value.

Exceptions

The Connection property was changed while a transaction was in progress.

Examples

The following example creates an OracleCommand and sets some of its properties.

public void CreateOracleCommand()
{
   string queryString = "SELECT * FROM Emp ORDER BY EmpNo";
   OracleCommand command = new OracleCommand(queryString);
   command.CommandType = CommandType.Text;
}
Public Sub CreateOracleCommand()
    Dim queryString As String = _
       "SELECT * FROM Emp ORDER BY EmpNo"
    Dim command As New OracleCommand(queryString)
    command.CommandType = CommandType.Text
End Sub

Remarks

You cannot set the Connection, CommandType, and CommandText properties if the current connection is performing an execute or fetch operation.

If you set Connection while a transaction is in progress and the Transaction property is not null, an InvalidOperationException is generated. If you set Connection after the transaction has been committed or rolled back, and the Transaction property is not null, the Transaction property is then set to a null value.

Applies to

See also