Skip to main content
.NET Framework Class Library
OracleDataAdapter Class

Note: This API is now obsolete.

Represents a set of data commands and a connection to a database that are used to fill the DataSet and update the database. This class cannot be inherited.

Inheritance Hierarchy
SystemObject
   SystemMarshalByRefObject
     System.ComponentModelComponent
       System.Data.CommonDataAdapter
         System.Data.CommonDbDataAdapter
          System.Data.OracleClientOracleDataAdapter

Namespace:   System.Data.OracleClient
Assembly:  System.Data.OracleClient (in System.Data.OracleClient.dll)
Syntax
<[%$TOPIC/wad8ktsk_en-us_VS_110_3_0_0_0_0%]("OracleDataAdapter has been deprecated. http://go.microsoft.com/fwlink/?LinkID=144260",  _
	False)> _
Public NotInheritable Class OracleDataAdapter _
	Inherits [%$TOPIC/wad8ktsk_en-us_VS_110_3_0_0_0_1%] _
	Implements [%$TOPIC/wad8ktsk_en-us_VS_110_3_0_0_0_2%], [%$TOPIC/wad8ktsk_en-us_VS_110_3_0_0_0_3%], [%$TOPIC/wad8ktsk_en-us_VS_110_3_0_0_0_4%]
[[%$TOPIC/wad8ktsk_en-us_VS_110_3_0_1_0_0%]("OracleDataAdapter has been deprecated. http://go.microsoft.com/fwlink/?LinkID=144260", 
	false)]
public sealed class OracleDataAdapter : [%$TOPIC/wad8ktsk_en-us_VS_110_3_0_1_0_1%], 
	[%$TOPIC/wad8ktsk_en-us_VS_110_3_0_1_0_2%], [%$TOPIC/wad8ktsk_en-us_VS_110_3_0_1_0_3%], [%$TOPIC/wad8ktsk_en-us_VS_110_3_0_1_0_4%]
[[%$TOPIC/wad8ktsk_en-us_VS_110_3_0_2_0_0%](L"OracleDataAdapter has been deprecated. http://go.microsoft.com/fwlink/?LinkID=144260", 
	false)]
public ref class OracleDataAdapter sealed : public [%$TOPIC/wad8ktsk_en-us_VS_110_3_0_2_0_1%], 
	[%$TOPIC/wad8ktsk_en-us_VS_110_3_0_2_0_2%], [%$TOPIC/wad8ktsk_en-us_VS_110_3_0_2_0_3%], [%$TOPIC/wad8ktsk_en-us_VS_110_3_0_2_0_4%]
[<[%$TOPIC/wad8ktsk_en-us_VS_110_3_0_3_0_0%]>]
[<[%$TOPIC/wad8ktsk_en-us_VS_110_3_0_3_0_1%]("OracleDataAdapter has been deprecated. http://go.microsoft.com/fwlink/?LinkID=144260", 
    false)>]
type OracleDataAdapter =  
    class 
        inherit [%$TOPIC/wad8ktsk_en-us_VS_110_3_0_3_0_2%] 
        interface [%$TOPIC/wad8ktsk_en-us_VS_110_3_0_3_0_3%] 
        interface [%$TOPIC/wad8ktsk_en-us_VS_110_3_0_3_0_4%] 
        interface [%$TOPIC/wad8ktsk_en-us_VS_110_3_0_3_0_5%] 
    end
public final class OracleDataAdapter extends [%$TOPIC/wad8ktsk_en-us_VS_110_3_0_4_0_0%] implements [%$TOPIC/wad8ktsk_en-us_VS_110_3_0_4_0_1%], [%$TOPIC/wad8ktsk_en-us_VS_110_3_0_4_0_2%], [%$TOPIC/wad8ktsk_en-us_VS_110_3_0_4_0_3%]

The OracleDataAdapter type exposes the following members.

Constructors
  NameDescription
Public method OracleDataAdapterInitializes a new instance of the OracleDataAdapter class.
Public method OracleDataAdapter(OracleCommand)Initializes a new instance of the OracleDataAdapter class with the specified SQL SELECT statement.
Public method OracleDataAdapter(String, OracleConnection)Initializes a new instance of the OracleDataAdapter class with an SQL SELECT statement and an OracleConnection.
Public method OracleDataAdapter(String, String)Initializes a new instance of the OracleDataAdapter class with an SQL SELECT statement and a connection string.
Top
Properties
  NameDescription
Public property AcceptChangesDuringFillGets or sets a value indicating whether AcceptChanges is called on a DataRow after it is added to the DataTable during any of the Fill operations. (Inherited from DataAdapter.)
Public property AcceptChangesDuringUpdateGets or sets whether AcceptChanges is called during a Update. (Inherited from DataAdapter.)
Public property ContainerGets the IContainer that contains the Component. (Inherited from Component.)
Public property ContinueUpdateOnErrorGets or sets a value that specifies whether to generate an exception when an error is encountered during a row update. (Inherited from DataAdapter.)
Public property DeleteCommandGets or sets an SQL statement or stored procedure used to delete records in the database.
Protected property FillCommandBehaviorGets or sets the behavior of the command used to fill the data adapter. (Inherited from DbDataAdapter.)
Public property FillLoadOptionGets or sets the LoadOption that determines how the adapter fills the DataTable from the DbDataReader. (Inherited from DataAdapter.)
Public property InsertCommandGets or sets an SQL statement or stored procedure used to insert new records into the database.
Public property MissingMappingActionDetermines the action to take when incoming data does not have a matching table or column. (Inherited from DataAdapter.)
Public property MissingSchemaActionDetermines the action to take when existing DataSet schema does not match incoming data. (Inherited from DataAdapter.)
Public property ReturnProviderSpecificTypesGets or sets whether the Fill method should return provider-specific values or common CLS-compliant values. (Inherited from DataAdapter.)
Public property SelectCommandGets or sets an SQL statement or stored procedure used to select records in the database.
Public property SiteGets or sets the ISite of the Component. (Inherited from Component.)
Public property TableMappingsGets a collection that provides the master mapping between a source table and a DataTable. (Inherited from DataAdapter.)
Public property UpdateBatchSizeGets or sets a value that enables or disables batch processing support, and specifies the number of commands that can be executed in a batch. (Overrides DbDataAdapterUpdateBatchSize.)
Public property UpdateCommandGets or sets an SQL statement or stored procedure used to update records in the database.
Top
Methods
  NameDescription
Public method CreateObjRefCreates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from MarshalByRefObject.)
Public method DisposeReleases all resources used by the Component. (Inherited from Component.)
Public method Equals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Public method Fill(DataSet)Adds or refreshes rows in the DataSet. (Inherited from DbDataAdapter.)
Public method Fill(DataTable)Adds or refreshes rows in a specified range in the DataSet to match those in the data source using the DataTable name. (Inherited from DbDataAdapter.)
Public method Fill(DataSet, String)Adds or refreshes rows in the DataSet to match those in the data source using the DataSet and DataTable names. (Inherited from DbDataAdapter.)
Public method Fill(Int32, Int32, DataTable)Adds or refreshes rows in a DataTable to match those in the data source starting at the specified record and retrieving up to the specified maximum number of records. (Inherited from DbDataAdapter.)
Public method Fill(DataSet, Int32, Int32, String)Adds or refreshes rows in a specified range in the DataSet to match those in the data source using the DataSet and DataTable names. (Inherited from DbDataAdapter.)
Public method FillSchema(DataSet, SchemaType)Adds a DataTable named "Table" to the specified DataSet and configures the schema to match that in the data source based on the specified SchemaType. (Inherited from DbDataAdapter.)
Public method FillSchema(DataTable, SchemaType)Configures the schema of the specified DataTable based on the specified SchemaType. (Inherited from DbDataAdapter.)
Public method FillSchema(DataSet, SchemaType, String)Adds a DataTable to the specified DataSet and configures the schema to match that in the data source based upon the specified SchemaType and DataTable. (Inherited from DbDataAdapter.)
Public method GetFillParametersGets the parameters set by the user when executing an SQL SELECT statement. (Inherited from DbDataAdapter.)
Public method GetHashCodeServes as the default hash function. (Inherited from Object.)
Public method GetLifetimeServiceRetrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from MarshalByRefObject.)
Public method GetTypeGets the Type of the current instance. (Inherited from Object.)
Public method InitializeLifetimeServiceObtains a lifetime service object to control the lifetime policy for this instance. (Inherited from MarshalByRefObject.)
Public method ResetFillLoadOptionResets FillLoadOption to its default state and causes DataAdapterFill to honor AcceptChangesDuringFill. (Inherited from DataAdapter.)
Public method ShouldSerializeAcceptChangesDuringFillDetermines whether the AcceptChangesDuringFill property should be persisted. (Inherited from DataAdapter.)
Public method ShouldSerializeFillLoadOptionDetermines whether the FillLoadOption property should be persisted. (Inherited from DataAdapter.)
Public method ToStringReturns a String containing the name of the Component, if any. This method should not be overridden. (Inherited from Component.)
Public method Update(DataRow)Updates the values in the database by executing the respective INSERT, UPDATE, or DELETE statements for each inserted, updated, or deleted row in the specified array in the DataSet. (Inherited from DbDataAdapter.)
Public method Update(DataSet)Updates the values in the database by executing the respective INSERT, UPDATE, or DELETE statements for each inserted, updated, or deleted row in the specified DataSet. (Inherited from DbDataAdapter.)
Public method Update(DataTable)Updates the values in the database by executing the respective INSERT, UPDATE, or DELETE statements for each inserted, updated, or deleted row in the specified DataTable. (Inherited from DbDataAdapter.)
Public method Update(DataSet, String)Updates the values in the database by executing the respective INSERT, UPDATE, or DELETE statements for each inserted, updated, or deleted row in the DataSet with the specified DataTable name. (Inherited from DbDataAdapter.)
Top
Events
  NameDescription
Public event DisposedOccurs when the component is disposed by a call to the Dispose method. (Inherited from Component.)
Public event FillErrorReturned when an error occurs during a fill operation. (Inherited from DataAdapter.)
Public event RowUpdatedOccurs during an update operation after a command is executed against the database.
Public event RowUpdatingOccurs during Update before a command is executed against the data source.
Top
Explicit Interface Implementations
  NameDescription
Explicit interface implemetation Private method ICloneableCloneFor a description of this member, see ICloneableClone.
Explicit interface implemetation Private property IDataAdapterTableMappingsIndicates how a source table is mapped to a dataset table. (Inherited from DataAdapter.)
Explicit interface implemetation Private property IDbDataAdapterDeleteCommandFor a description of this member, see DeleteCommand.
Explicit interface implemetation Private property IDbDataAdapterInsertCommandFor a description of this member, see InsertCommand.
Explicit interface implemetation Private property IDbDataAdapterSelectCommandFor a description of this member, see SelectCommand.
Explicit interface implemetation Private property IDbDataAdapterUpdateCommandFor a description of this member, see UpdateCommand.
Top
Remarks

This type is deprecated and will be removed in a future version of the .NET Framework. For more information, see Oracle and ADO.NET.

The OracleDataAdapter serves as a bridge between a DataSet and database for retrieving and saving data. The OracleDataAdapter provides this bridge by using Fill to load data from the database into the DataSet, and using Update to send changes made in the DataSet back to the data source.

When the OracleDataAdapter fills a DataSet, it creates the necessary tables and columns for the returned data if they do not already exist. However, primary key information is not included in the implicitly created schema unless the MissingSchemaAction property is set to AddWithKey. You may also have the OracleDataAdapter create the schema of the DataSet, including primary key information, before filling it with data using FillSchema. For more information, see Adding Existing Constraints to a DataSet.

NoteNote

By default, numeric fields imported to a DataTable with Fill are mapped to OracleNumber objects. It is possible to overflow the OracleNumber, and throw an Oracle exception, by importing a non-integral numeric value that is either too large or too high precision for the OracleNumber's precision limitations. Refer to the description of OracleNumber for more information.

The OracleDataAdapter also includes the SelectCommand, InsertCommand, DeleteCommand, UpdateCommand, and TableMappings properties to facilitate loading and updating of data.

The .NET Framework Data Provider for Oracle does not support batched SQL statements. However, it does allow you to use multiple REF CURSOR output parameters to fill a DataSet, each in its own DataTable. You must define the parameters, mark them as output parameters, and indicate that they are REF CURSOR data types. Note that you cannot use the Update method when the OracleDataAdapter is filled using REF CURSOR parameters returned by a stored procedure, because Oracle does not provide the information necessary to determine what the table name and column names are when the SQL statement is executed. The following C# example assumes that you have created this stored procedure.

Create the following Oracle package on the Oracle server.

CREATE OR REPLACE PACKAGE CURSPKG AS 
   TYPE T_CURSOR IS REF CURSOR; 
   PROCEDURE OPEN_ONE_CURSOR (N_EMPNO IN NUMBER, 
      IO_CURSOR OUT T_CURSOR); 
   PROCEDURE OPEN_TWO_CURSORS (EMPCURSOR OUT T_CURSOR, 
      DEPTCURSOR OUT T_CURSOR);
END CURSPKG;
/

Create the following Oracle package body on the Oracle server.

CREATE OR REPLACE PACKAGE BODY CURSPKG AS 
    PROCEDURE OPEN_ONE_CURSOR (N_EMPNO IN NUMBER, 
                               IO_CURSOR OUT T_CURSOR) 
    IS 
        V_CURSOR T_CURSOR; 
    BEGIN 
        IF N_EMPNO <> 0 THEN 
             OPEN V_CURSOR FOR 
             SELECT EMP.EMPNO, EMP.ENAME, DEPT.DEPTNO, DEPT.DNAME 
                  FROM EMP, DEPT 
                  WHERE EMP.DEPTNO = DEPT.DEPTNO 
                        AND EMP.EMPNO = N_EMPNO; 
        ELSE 
             OPEN V_CURSOR FOR 
             SELECT EMP.EMPNO, EMP.ENAME, DEPT.DEPTNO, DEPT.DNAME 
                  FROM EMP, DEPT 
                  WHERE EMP.DEPTNO = DEPT.DEPTNO; 
        END IF; 
        IO_CURSOR := V_CURSOR; 
    END OPEN_ONE_CURSOR; 
    PROCEDURE OPEN_TWO_CURSORS (EMPCURSOR OUT T_CURSOR, 
                                DEPTCURSOR OUT T_CURSOR) 
    IS 
        V_CURSOR1 T_CURSOR; 
        V_CURSOR2 T_CURSOR; 
    BEGIN 
        OPEN V_CURSOR1 FOR SELECT * FROM EMP; 
        OPEN V_CURSOR2 FOR SELECT * FROM DEPT; 
        EMPCURSOR  := V_CURSOR1; 
        DEPTCURSOR := V_CURSOR2; 
    END OPEN_TWO_CURSORS; 
END CURSPKG;
 /

The following C# example demonstrates how you might obtain table and column information using the stored procedure.

// GetConnectionString() returns a connection string for
// the data source.

string connString = GetConnectionString();
DataSet ds = new DataSet();
OracleConnection conn = new OracleConnection(connString);
OracleCommand cmd = conn.CreateCommand();

cmd.CommandText = "CURSPKG.OPEN_TWO_CURSORS";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("EMPCURSOR", OracleType.Cursor).Direction = 
       ParameterDirection.Output;
cmd.Parameters.Add("DEPTCURSOR", OracleType.Cursor).Direction = 
       ParameterDirection.Output;

OracleDataAdapter da = new OracleDataAdapter(cmd);
da.TableMappings.Add("Table", "Emp");
da.TableMappings.Add("Table1", "Dept");
da.Fill(ds);

ds.Relations.Add("EmpDept", ds.Tables["Dept"].Columns["Deptno"], 
      ds.Tables["Emp"].Columns["Deptno"], false);

The following Visual Basic example demonstrates how to use an OracleDataAdapter to fill a DataSet using an Oracle REF CURSOR. These examples use tables that are defined in the Oracle Scott/Tiger schema, and require the following PL/SQL package and package body. You must create these on your server to use the examples.

Create the following Oracle package on the Oracle server.

CREATE OR REPLACE PACKAGE CURSPKG AS 
   TYPE T_CURSOR IS REF CURSOR; 
   PROCEDURE OPEN_ONE_CURSOR (N_EMPNO IN NUMBER, 
      IO_CURSOR OUT T_CURSOR); 
   PROCEDURE OPEN_TWO_CURSORS (EMPCURSOR OUT T_CURSOR, 
      DEPTCURSOR OUT T_CURSOR);
END CURSPKG;
/

Create the following Oracle package body on the Oracle server.

CREATE OR REPLACE PACKAGE BODY CURSPKG AS 
    PROCEDURE OPEN_ONE_CURSOR (N_EMPNO IN NUMBER, 
                               IO_CURSOR OUT T_CURSOR) 
    IS 
        V_CURSOR T_CURSOR; 
    BEGIN 
        IF N_EMPNO <> 0 THEN 
             OPEN V_CURSOR FOR 
             SELECT EMP.EMPNO, EMP.ENAME, DEPT.DEPTNO, DEPT.DNAME 
                  FROM EMP, DEPT 
                  WHERE EMP.DEPTNO = DEPT.DEPTNO 
                        AND EMP.EMPNO = N_EMPNO; 
        ELSE 
             OPEN V_CURSOR FOR 
             SELECT EMP.EMPNO, EMP.ENAME, DEPT.DEPTNO, DEPT.DNAME 
                  FROM EMP, DEPT 
                  WHERE EMP.DEPTNO = DEPT.DEPTNO; 
        END IF; 
        IO_CURSOR := V_CURSOR; 
    END OPEN_ONE_CURSOR; 
    PROCEDURE OPEN_TWO_CURSORS (EMPCURSOR OUT T_CURSOR, 
                                DEPTCURSOR OUT T_CURSOR) 
    IS 
        V_CURSOR1 T_CURSOR; 
        V_CURSOR2 T_CURSOR; 
    BEGIN 
        OPEN V_CURSOR1 FOR SELECT * FROM EMP; 
        OPEN V_CURSOR2 FOR SELECT * FROM DEPT; 
        EMPCURSOR  := V_CURSOR1; 
        DEPTCURSOR := V_CURSOR2; 
    END OPEN_TWO_CURSORS; 
END CURSPKG;
 /

This Visual Basic example executes a PL/SQL stored procedure that returns two REF CURSOR parameters, and fills a DataSet with the rows that are returned.

' GetConnectionString() returns a connection string for
' the data source.

    Dim connString As New String(GetConnectionString())
    Dim ds As New DataSet()
    Dim conn As New OracleConnection(connString)
    Dim cmd As OracleCommand = conn.CreateCommand()

    cmd.CommandText = "CURSPKG.OPEN_TWO_CURSORS"
    cmd.CommandType = CommandType.StoredProcedure
    cmd.Parameters.Add("EMPCURSOR", OracleType.Cursor).Direction = _
       ParameterDirection.Output
    cmd.Parameters.Add("DEPTCURSOR", OracleType.Cursor).Direction = _
       ParameterDirection.Output

    Dim da As New OracleDataAdapter(cmd)
    da.TableMappings.Add("Table", "Emp")
    da.TableMappings.Add("Table1", "Dept")
    da.Fill(ds)

    ds.Relations.Add("EmpDept", ds.Tables("Dept").Columns("Deptno"), _
      ds.Tables("Emp").Columns("Deptno"), False)

After using the OracleDataAdapter to perform a Fill or FillSchema operation, the DataColumn.ReadOnly property always returns false, regardless of whether a column can be updated or not, because the Oracle server does not return this information.

Version Information

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1
Obsolete (compiler warning) in 4.6
Obsolete (compiler warning) in 4.6
Obsolete (compiler warning) in 4.5
Obsolete (compiler warning) in 4.5.1
Obsolete (compiler warning) in 4.5.2
Obsolete (compiler warning) in 4
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.