ADO.NET Provider for Sage Intacct

Build 23.0.8839

DataReader を使用したクエリ

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

SageIntacctDataReader の使用

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

C#

string connectionString = "User='myusername';CompanyID='TestCompany';Password='mypassword';SenderID='Test';SenderPassword='abcde123';";

using (SageIntacctConnection connection = new SageIntacctConnection(connectionString)) {
  SageIntacctCommand cmd = new SageIntacctCommand("SELECT * FROM Customer", connection);
  
  SageIntacctDataReader rdr = cmd.ExecuteReader();

  while (rdr.Read()) {
    Console.WriteLine(String.Format("\t{0} --> \t\t{1}", rdr["Name"], rdr["TotalDue"]));
  }
}

VB.NET

Dim connectionString As String = "User='myusername';CompanyID='TestCompany';Password='mypassword';SenderID='Test';SenderPassword='abcde123';"

Using connection As New SageIntacctConnection(connectionString)
  Dim cmd As New SageIntacctCommand("SELECT * FROM Customer", connection)

  Dim rdr As SageIntacctDataReader = cmd.ExecuteReader()

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

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