OracleCommand Constructors

Definition

Initializes a new instance of the OracleCommand.

Overloads

OracleCommand()

Initializes a new instance of the OracleCommand.

OracleCommand(String)

Initializes a new instance of the OracleCommand class with the text of the query.

OracleCommand(String, OracleConnection)

Initializes a new instance of the OracleCommand class with the text of the query and an OracleConnection object.

OracleCommand(String, OracleConnection, OracleTransaction)

Initializes a new instance of the OracleCommand class with the text of the query, an OracleConnection object, and an OracleTransaction.

OracleCommand()

Initializes a new instance of the OracleCommand.

public:
 OracleCommand();
public OracleCommand ();
Public Sub New ()

Examples

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

public void CreateOracleCommand()
{
   OracleCommand command = new OracleCommand();
   command.CommandType = CommandType.Text;
}
Public Sub CreateOracleCommand()
    Dim command As New OracleCommand()
    command.CommandType = CommandType.Text
End Sub

Remarks

The base constructor initializes all fields to their default values. The following table shows initial property values for an instance of OracleCommand.

Properties Initial Value
CommandText empty string ("")
CommandType Text
Connection null

See also

Applies to

OracleCommand(String)

Initializes a new instance of the OracleCommand class with the text of the query.

public:
 OracleCommand(System::String ^ commandText);
public OracleCommand (string commandText);
new System.Data.OracleClient.OracleCommand : string -> System.Data.OracleClient.OracleCommand
Public Sub New (commandText As String)

Parameters

commandText
String

The text of the query.

See also

Applies to

OracleCommand(String, OracleConnection)

Initializes a new instance of the OracleCommand class with the text of the query and an OracleConnection object.

public:
 OracleCommand(System::String ^ commandText, System::Data::OracleClient::OracleConnection ^ connection);
public OracleCommand (string commandText, System.Data.OracleClient.OracleConnection connection);
new System.Data.OracleClient.OracleCommand : string * System.Data.OracleClient.OracleConnection -> System.Data.OracleClient.OracleCommand
Public Sub New (commandText As String, connection As OracleConnection)

Parameters

commandText
String

The text of the query.

connection
OracleConnection

An OracleConnection object that represents the connection to a database.

Examples

The following example creates an OracleCommand.

public void CreateOracleCommand()
{
   OracleConnection connection = new OracleConnection("Data Source=Oracle8i;Integrated Security=yes");
   string queryString = "SELECT * FROM Emp ORDER BY EmpNo";
   OracleCommand command = new OracleCommand(queryString, connection);
}
Public Sub CreateOracleCommand()
    Dim connection As New OracleConnection _
       ("Data Source=Oracle8i;Integrated Security=yes")
    Dim queryString As String = _
       "SELECT * FROM Emp ORDER BY EmpNo"
    Dim command As New OracleCommand(queryString, connection)
End Sub

See also

Applies to

OracleCommand(String, OracleConnection, OracleTransaction)

Initializes a new instance of the OracleCommand class with the text of the query, an OracleConnection object, and an OracleTransaction.

public:
 OracleCommand(System::String ^ commandText, System::Data::OracleClient::OracleConnection ^ connection, System::Data::OracleClient::OracleTransaction ^ tx);
public OracleCommand (string commandText, System.Data.OracleClient.OracleConnection connection, System.Data.OracleClient.OracleTransaction tx);
new System.Data.OracleClient.OracleCommand : string * System.Data.OracleClient.OracleConnection * System.Data.OracleClient.OracleTransaction -> System.Data.OracleClient.OracleCommand
Public Sub New (commandText As String, connection As OracleConnection, tx As OracleTransaction)

Parameters

commandText
String

The text of the query.

connection
OracleConnection

An OracleConnection object that represents the connection to a database.

tx
OracleTransaction

The OracleTransaction in which the OracleCommand executes.

Examples

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

public void CreateOracleCommand(string connectionString)
{
    using (OracleConnection connection = new OracleConnection(connectionString))
    {
        connection.Open();
        OracleTransaction transaction = connection.BeginTransaction();
        string queryString = "SELECT * FROM Emp ORDER BY EmpNo";
        OracleCommand command = new OracleCommand(queryString, connection, transaction);
        command.CommandType = CommandType.Text;
    }
}
Public Sub CreateOracleCommand(ByVal connectionString As String)
    Using connection As New OracleConnection(connectionString)
        connection.Open()
        Dim transaction As OracleTransaction = connection.BeginTransaction()
        Dim queryString As String = _
           "SELECT * FROM Emp ORDER BY EmpNo"
        Dim command As New OracleCommand(queryString, connection, transaction)
        command.CommandType = CommandType.Text
    End Using
End Sub

Remarks

The following table shows initial property values for an instance of this implementation of the OracleCommand.

Properties Initial Value
CommandText cmdText
CommandType Text
Connection A new OracleConnection that is the value for the connection parameter.

You can change the value for any of these parameters by setting the related property.

See also

Applies to