This documentation is archived and is not being maintained.

OracleCommand Constructor (String, OracleConnection, OracleTransaction)

.NET Framework 1.1
Note: This namespace, class, or member is supported only in version 1.1 of the .NET Framework.

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

[Visual Basic]
Public Sub New( _
   ByVal commandText As String, _
   ByVal connection As OracleConnection, _
   ByVal tx As OracleTransaction _
public OracleCommand(
   string commandText,
 OracleConnection connection,
 OracleTransaction tx
public: OracleCommand(
   String* commandText,
 OracleConnection* connection,
 OracleTransaction* tx
public function OracleCommand(
   commandText : String,
 connection : OracleConnection,
 tx : OracleTransaction


The text of the query.
An OracleConnection object that represents the connection to a database.
The OracleTransaction in which the OracleCommand executes.


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.


[Visual Basic, C#, C++] The following example creates an OracleCommand and sets some of its properties.

[Visual Basic] 
Public Sub CreateMyOracleCommand()
    Dim myConnection As New OracleConnection _
       ("Data Source=Oracle8i;Integrated Security=yes")
    Dim myTrans As OracleTransaction = myConnection.BeginTransaction()
    Dim mySelectQuery As String = _
       "SELECT * FROM Emp ORDER BY EmpNo"
    Dim myCommand As New OracleCommand(mySelectQuery, myConnection, myTrans)
    myCommand.CommandType = CommandType.Text
End Sub

public void CreateMyOracleCommand() 
   OracleConnection myConnection = new OracleConnection("Data Source=Oracle8i;Integrated Security=yes");
   OracleTransaction myTrans = myConnection.BeginTransaction();
   string mySelectQuery = "SELECT * FROM Emp ORDER BY EmpNo";
   OracleCommand myCommand = new OracleCommand(mySelectQuery, myConnection,myTrans);
   myCommand.CommandType = CommandType.Text;

void CreateMyOracleCommand() 
   OracleConnection* myConnection = new OracleConnection(S"Data Source=Oracle8i;Integrated Security=yes");
   OracleTransaction* myTrans = myConnection->BeginTransaction();
   String* mySelectQuery = S"SELECT * FROM Emp ORDER BY EmpNo";
   OracleCommand* myCommand = new OracleCommand(mySelectQuery, myConnection,myTrans);
   myCommand->CommandType = CommandType::Text;

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

.NET Framework Security: 

See Also

OracleCommand Class | OracleCommand Members | System.Data.OracleClient Namespace | OracleCommand Constructor Overload List