ADO.NET Provider for Sage Intacct

Build 23.0.8839

DataAdapter を使用したクエリ

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

SageIntacctDataAdapter の使用

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

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

C#

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

using (SageIntacctConnection connection = new SageIntacctConnection(connectionString)) {
  SageIntacctDataAdapter dataAdapter = new SageIntacctDataAdapter(
  "SELECT Name, TotalDue FROM Customer", connection);

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

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

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

VB.NET

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

Using connection As New SageIntacctConnection(connectionString)
  Dim dataAdapter As New SageIntacctDataAdapter("SELECT Name, TotalDue FROM Customer", connection)

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

  Console.WriteLine("Contents of Customer.")

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

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