Export (0) Print
Expand All

OracleCommand Class

Represents an SQL statement or stored procedure to execute against a database. This class cannot be inherited.

Namespace: System.Data.OracleClient
Assembly: System.Data.OracleClient (in system.data.oracleclient.dll)

'Declaration
Public NotInheritable Class OracleCommand
	Inherits DbCommand
	Implements ICloneable
'Usage
Dim instance As OracleCommand

public final class OracleCommand extends DbCommand implements ICloneable
public final class OracleCommand extends DbCommand implements ICloneable

The OracleCommand class provides the following methods for executing commands against a data source:

Item

Description

ExecuteReader

Executes commands that return rows.

ExecuteOracleNonQuery

Executes an SQL statement against the Connection and returns the number of rows affected.

ExecuteNonQuery

Executes commands such as SQL INSERT, DELETE, UPDATE, and SET statements.

ExecuteScalar

Retrieves a single value (for example, an aggregate value) from a database as a .NET Framework data type.

ExecuteOracleScalar

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.

NoteNote

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 Sub ReadMyData(ByVal connectionString As String)
    Dim queryString As String = "SELECT EmpNo, DeptNo FROM Scott.Emp"
    Using connection As New OracleConnection(connectionString)
        Dim command As New OracleCommand(queryString, connection)
        connection.Open()
        Dim reader As OracleDataReader = command.ExecuteReader()
        Try
            While reader.Read()
                Console.WriteLine(reader.GetInt32(0) & ", " _
                   & reader.GetInt32(1))
            End While
        Finally
            ' always call Close when done reading.
            reader.Close()
        End Try
    End Using
End Sub

System.Object
   System.MarshalByRefObject
     System.ComponentModel.Component
       System.Data.Common.DbCommand
        System.Data.OracleClient.OracleCommand

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows 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 .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1

Community Additions

ADD
Show:
© 2014 Microsoft