ADO.NET Provider for Acumatica

Build 23.0.8839

DataAdapter を使用したクエリ

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

AcumaticaDataAdapter の使用

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

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

C#

string connectionString = "Url = https://try.acumatica.com/ISV/entity/Default/17.200.001/;User=user;Password=password;Company=CompanyName;";

using (AcumaticaConnection connection = new AcumaticaConnection(connectionString)) {
  AcumaticaDataAdapter dataAdapter = new AcumaticaDataAdapter(
  "SELECT Id, location_displayName FROM Events", connection);

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

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

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

VB.NET

Dim connectionString As String = "Url = https://try.acumatica.com/ISV/entity/Default/17.200.001/;User=user;Password=password;Company=CompanyName;"

Using connection As New AcumaticaConnection(connectionString)
  Dim dataAdapter As New AcumaticaDataAdapter("SELECT Id, location_displayName FROM Events", connection)

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

  Console.WriteLine("Contents of Events.")

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

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