日本語PDF

OracleDataAdapterクラス

OracleDataAdapterオブジェクトは、DataSetを移入し、DataSetにおける変更をOracle Databaseに反映させるデータ・プロバイダ・オブジェクトを表します。

クラスの継承

System.Object

  System.MarshalByRefObject

    System.ComponentModel.Component

      System.Data.Common.DataAdapter

        System.Data.Common.DbDataAdapter

          Oracle.DataAccess.Client.OracleDataAdapter

宣言

// C#
public sealed class OracleDataAdapter : DbDataAdapter, IDbDataAdapter

要件

プロバイダ ODP.NET管理対象外ドライバ ODP.NET管理対象ドライバ ODP.NET Core

アセンブリ

Oracle.DataAccess.dll

Oracle.ManagedDataAccess.dll

Oracle.ManagedDataAccess.dll

ネームスペース

Oracle.DataAccess.Client

Oracle.ManagedDataAccess.Client

Oracle.ManagedDataAccess.Client

.NET Framework

4.5, 4.6, 4.7

4.5, 4.6, 4.7

4.6.1以降

.NET Core

-

-

2.1以降

スレッド安全性

パブリック静的メソッドはスレッドセーフですが、インスタンス・メソッドではスレッド安全性は保証されません。

次の例では、EMP表の更新にOracleDataAdapterおよびデータセットが使用されています。

// C#
 
using System;
using System.Data;
using Oracle.DataAccess.Client;
 
class OracleDataAdapterSample
{
  static void Main()
  {
    string constr = "User Id=scott;Password=tiger;Data Source=oracle";
    string cmdstr = "SELECT empno, sal from emp";
 
    // Create the adapter with the selectCommand txt and the
    // connection string
    OracleDataAdapter adapter = new OracleDataAdapter(cmdstr, constr);
 
    // Create the builder for the adapter to automatically generate
    // the Command when needed
    OracleCommandBuilder builder = new OracleCommandBuilder(adapter);
 
    // Create and fill the DataSet using the EMP
    DataSet dataset = new DataSet();
    adapter.Fill(dataset, "EMP");
 
    // Get the EMP table from the dataset
    DataTable table = dataset.Tables["EMP"];
 
    // Indicate DataColumn EMPNO is unique
    // This is required by the OracleCommandBuilder to update the EMP table
    table.Columns["EMPNO"].Unique = true;
 
    // Get the first row from the EMP table
    DataRow row = table.Rows[0];
 
    // Update the salary
    double sal = double.Parse(row["SAL"].ToString());
    row["SAL"] = sal + .01;
 
    // Now update the EMP using the adapter
    // The OracleCommandBuilder will create the UpdateCommand for the
    // adapter to update the EMP table
    adapter.Update(dataset, "EMP");
 
    Console.WriteLine("Row updated successfully");
  }
}