ADO.NET Provider for Zoho Books

Build 22.0.8479

DataAdapter を使用したクエリ

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

ZohoBooksDataAdapter の使用

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

次の例は、INVOICES テーブルのInvoiceId カラムとInvoiceNumber カラムを選択します。

C#

string connectionString = "InitiateOAuth=GETANDREFRESH;OrganizationId=YourOrganizationId;AccountsServer=YourAccountServerURL";

using (ZohoBooksConnection connection = new ZohoBooksConnection(connectionString)) {
  ZohoBooksDataAdapter dataAdapter = new ZohoBooksDataAdapter(
  "SELECT InvoiceId, InvoiceNumber FROM INVOICES", connection);

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

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

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

VB.NET

Dim connectionString As String = "InitiateOAuth=GETANDREFRESH;OrganizationId=YourOrganizationId;AccountsServer=YourAccountServerURL"

Using connection As New ZohoBooksConnection(connectionString)
  Dim dataAdapter As New ZohoBooksDataAdapter("SELECT InvoiceId, InvoiceNumber FROM INVOICES", connection)

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

  Console.WriteLine("Contents of INVOICES.")

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

Copyright (c) 2023 CData Software, Inc. - All rights reserved.
Build 22.0.8479