ADO.NET Provider for Acumatica

Build 23.0.8839

DataReader を使用したクエリ

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

AcumaticaDataReader の使用

AcumaticaDataReader はページ単位でデータを取得できるため、AcumaticaDataAdapter よりもデータの取得が高速です。AcumaticaDataReader からデータを読み取っていくと、必要に応じて一定の間隔で、データソースからの結果の次のページが要求されます。このため、結果が高速に返されます。 次の例は、Events テーブルからすべてのカラムを選択します。

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)) {
  AcumaticaCommand cmd = new AcumaticaCommand("SELECT * FROM Events", connection);
  
  AcumaticaDataReader rdr = cmd.ExecuteReader();

  while (rdr.Read()) {
    Console.WriteLine(String.Format("\t{0} --> \t\t{1}", rdr["Id"], rdr["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 cmd As New AcumaticaCommand("SELECT * FROM Events", connection)

  Dim rdr As AcumaticaDataReader = cmd.ExecuteReader()

  While rdr.Read()
    Console.WriteLine([String].Format(vbTab & "{0} --> " & vbTab & vbTab & "{1}", rdr("Id"), rdr("location_displayName")))
  End While
End Using

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