ADO.NET Provider for PCA Accounting

Build 23.0.8839

DataAdapter を使用したクエリ

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

PCAAccountingDataAdapter の使用

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

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

C#

string connectionString = "InitiateOAuth=GETANDREFRESH;DefaultDataArea=P20V01C081KON0002;DataCenter=east02;";

using (PCAAccountingConnection connection = new PCAAccountingConnection(connectionString)) {
  PCAAccountingDataAdapter dataAdapter = new PCAAccountingDataAdapter(
  "SELECT Id, Name FROM Kmk", connection);

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

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

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

VB.NET

Dim connectionString As String = "InitiateOAuth=GETANDREFRESH;DefaultDataArea=P20V01C081KON0002;DataCenter=east02;"

Using connection As New PCAAccountingConnection(connectionString)
  Dim dataAdapter As New PCAAccountingDataAdapter("SELECT Id, Name FROM Kmk", connection)

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

  Console.WriteLine("Contents of Kmk.")

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

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