ADO.NET Provider for Pinterest

Build 23.0.8839

DataAdapter を使用したクエリ

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

PinterestDataAdapter の使用

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

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

C#

string connectionString = "InitiateOAuth=GETANDREFRESH;OAuthClientId=YourClientId;OAuthClientSecret=YourClientSecret;CallbackURL='https://localhost:33333'";

using (PinterestConnection connection = new PinterestConnection(connectionString)) {
  PinterestDataAdapter dataAdapter = new PinterestDataAdapter(
  "SELECT Name, Country FROM AdAccounts", connection);

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

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

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

VB.NET

Dim connectionString As String = "InitiateOAuth=GETANDREFRESH;OAuthClientId=YourClientId;OAuthClientSecret=YourClientSecret;CallbackURL='https://localhost:33333'"

Using connection As New PinterestConnection(connectionString)
  Dim dataAdapter As New PinterestDataAdapter("SELECT Name, Country FROM AdAccounts", connection)

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

  Console.WriteLine("Contents of AdAccounts.")

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

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