ADO.NET Provider for Certinia

Build 23.0.8839

DataAdapter を使用したクエリ

CData ADO.NET Provider for Certinia では、次の2つのネイティブ.NET インターフェースを使用して、Certinia からデータを取得できます。FinancialForceDataAdapter オブジェクトおよびFinancialForceDataReader オブジェクト。各オブジェクトは同じタスク(データの取得)を実行しますが、実行方法が異なります。FinancialForceDataAdapter オブジェクトはクエリに一致するすべてのデータを取得しますが、FinancialForceDataReader オブジェクトは必要に応じてインクリメントしながら一部のデータだけをフェッチします。

FinancialForceDataAdapter の使用

アダプターのFill メソッドを使用して、データソースからデータを取得します。空のDataTable インスタンスがFill メソッドへの引数として渡されます。このメソッドが戻ってきたとき、DataTable インスタンスにはクエリされたデータが設定されています。Fill メソッドは、戻る前にデータソースからすべてのデータを取得する必要があるため、FinancialForceDataAdapter はFinancialForceDataReader よりも時間がかかります。

次の例は、Account テーブルのBillingState カラムとName カラムを選択します。

C#

string connectionString = "User=myUser;Password=myPassword;Security Token=myToken;";

using (FinancialForceConnection connection = new FinancialForceConnection(connectionString)) {
  FinancialForceDataAdapter dataAdapter = new FinancialForceDataAdapter(
  "SELECT BillingState, Name FROM Account", connection);

  DataTable table = new DataTable();
  dataAdapter.Fill(table);

  Console.WriteLine("Contents of Account.");

  foreach (DataRow row in table.Rows) {
    Console.WriteLine("{0}: {1}", row["BillingState"], row["Name"]);
  }
}

VB.NET

Dim connectionString As String = "User=myUser;Password=myPassword;Security Token=myToken;"

Using connection As New FinancialForceConnection(connectionString)
  Dim dataAdapter As New FinancialForceDataAdapter("SELECT BillingState, Name FROM Account", connection)

  Dim table As New DataTable()
  dataAdapter.Fill(table)

  Console.WriteLine("Contents of Account.")

  For Each row As DataRow In table.Rows
    Console.WriteLine("{0}: {1}", row("BillingState"), row("Name"))
  Next
End Using

Copyright (c) 2024 CData Software, Inc. - All rights reserved.
Build 23.0.8839