ADO.NET Provider for HubSpot

Build 23.0.8839

DataAdapter を使用したクエリ

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

HubSpotDataAdapter の使用

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

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

C#

string connectionString = "InitiateOAuth=GETANDREFRESH;";

using (HubSpotConnection connection = new HubSpotConnection(connectionString)) {
  HubSpotDataAdapter dataAdapter = new HubSpotDataAdapter(
  "SELECT City, Country 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["City"], row["Country"]);
  }
}

VB.NET

Dim connectionString As String = "InitiateOAuth=GETANDREFRESH;"

Using connection As New HubSpotConnection(connectionString)
  Dim dataAdapter As New HubSpotDataAdapter("SELECT City, Country 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("City"), row("Country"))
  Next
End Using

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