ADO.NET Provider for Zoho Inventory

Build 23.0.8839

DataAdapter を使用したクエリ

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

Zoho InventoryDataAdapter の使用

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

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

C#

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

using (Zoho InventoryConnection connection = new Zoho InventoryConnection(connectionString)) {
  Zoho InventoryDataAdapter dataAdapter = new Zoho InventoryDataAdapter(
  "SELECT Id, CustomerName FROM Contacts", connection);

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

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

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

VB.NET

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

Using connection As New Zoho InventoryConnection(connectionString)
  Dim dataAdapter As New Zoho InventoryDataAdapter("SELECT Id, CustomerName FROM Contacts", connection)

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

  Console.WriteLine("Contents of Contacts.")

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

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