Export (0) Print
Expand All

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 _
)
[C#]
public OracleCommand(
   string commandText,
 OracleConnection connection,
 OracleTransaction tx
);
[C++]
public: OracleCommand(
   String* commandText,
 OracleConnection* connection,
 OracleTransaction* tx
);
[JScript]
public function OracleCommand(
   commandText : String,
 connection : OracleConnection,
 tx : OracleTransaction
);

Parameters

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

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.

Example

[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")
    myConnection.Open()
    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


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


[C++] 
public:
void CreateMyOracleCommand() 
{
   OracleConnection* myConnection = new OracleConnection(S"Data Source=Oracle8i;Integrated Security=yes");
   myConnection->Open();
   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.

Requirements

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

Show:
© 2014 Microsoft