OracleCommand Class
Assembly: System.Data.OracleClient (in system.data.oracleclient.dll)
The OracleCommand class provides the following methods for executing commands against a data source:
| Item | Description |
|---|---|
| Executes commands that return rows. | |
| Executes an SQL statement against the Connection and returns the number of rows affected. | |
| Executes commands such as SQL INSERT, DELETE, UPDATE, and SET statements. | |
| Retrieves a single value (for example, an aggregate value) from a database as a .NET Framework data type. | |
| Retrieves a single value (for example, an aggregate value) from a database as an Oracle-specific data type. |
You can reset the CommandText property and reuse the OracleCommand object.
If execution of the command results in a fatal OracleException, the OracleConnection may close. However, the user can reopen the connection and continue.
Note: |
|---|
| Unlike the Command object in the other .NET Framework data providers (SQL Server, OLE DB, and ODBC), the OracleCommand object does not support a CommandTimeout property. Setting a command timeout has no effect and the value returned is always zero. |
The following example uses the ExecuteReader method of OracleCommand, along with OracleDataReader and OracleConnection, to select rows from a table.
public void ReadMyData(string connectionString) { string queryString = "SELECT EmpNo, DeptNo FROM Scott.Emp"; using (OracleConnection connection = new OracleConnection(connectionString)) { OracleCommand command = new OracleCommand(queryString, connection); connection.Open(); OracleDataReader reader = command.ExecuteReader(); try { while (reader.Read()) { Console.WriteLine(reader.GetInt32(0) + ", " + reader.GetInt32(1)); } } finally { // always call Close when done reading. reader.Close(); } } }
System.MarshalByRefObject
System.ComponentModel.Component
System.Data.Common.DbCommand
System.Data.OracleClient.OracleCommand
Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.Reference
OracleCommand MembersSystem.Data.OracleClient Namespace
Note: