ADO.NET Provider for Zoho Creator

Build 23.0.8839

DataAdapter を使用したクエリ

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

ZohoCreatorDataAdapter の使用

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

次の例は、Leave_Types テーブルのID カラムとLeave_Type カラムを選択します。

C#

string connectionString = "InitiateOAuth=GETANDREFRESH;";

using (ZohoCreatorConnection connection = new ZohoCreatorConnection(connectionString)) {
  ZohoCreatorDataAdapter dataAdapter = new ZohoCreatorDataAdapter(
  "SELECT ID, Leave_Type FROM [CData].[Employee Management].Leave_Types", connection);

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

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

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

VB.NET

Dim connectionString As String = "InitiateOAuth=GETANDREFRESH;"

Using connection As New ZohoCreatorConnection(connectionString)
  Dim dataAdapter As New ZohoCreatorDataAdapter("SELECT ID, Leave_Type FROM [CData].[Employee Management].Leave_Types", connection)

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

  Console.WriteLine("Contents of Leave_Types.")

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

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