ADO.NET Provider for Zoho CRM

Build 22.0.8479

DataAdapter を使用したクエリ

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

ZohoCRMDataAdapter の使用

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

次の例は、Accounts テーブルのAccountName カラムとAccountNumber カラムを選択します。

C#

string connectionString = "InitiateOAuth=GETANDREFRESH;";

using (ZohoCRMConnection connection = new ZohoCRMConnection(connectionString)) {
  ZohoCRMDataAdapter dataAdapter = new ZohoCRMDataAdapter(
  "SELECT AccountName, AccountNumber FROM Accounts", connection);

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

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

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

VB.NET

Dim connectionString As String = "InitiateOAuth=GETANDREFRESH;"

Using connection As New ZohoCRMConnection(connectionString)
  Dim dataAdapter As New ZohoCRMDataAdapter("SELECT AccountName, AccountNumber FROM Accounts", connection)

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

  Console.WriteLine("Contents of Accounts.")

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

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