ADO.NET Provider for SurveyMonkey

Build 23.0.8839

DataAdapter を使用したクエリ

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

SurveyMonkeyDataAdapter の使用

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

次の例は、MySurvey_Responses テーブルのRespondentId カラムとChoiceId カラムを選択します。

C#

string connectionString = "InitiateOAuth=GETANDREFRESH;OAuthClientId=MyOAuthClientId;OAuthClientSecret=MyOAuthClientSecret;CallbackURL=http://localhost:portNumber;";

using (SurveyMonkeyConnection connection = new SurveyMonkeyConnection(connectionString)) {
  SurveyMonkeyDataAdapter dataAdapter = new SurveyMonkeyDataAdapter(
  "SELECT RespondentId, ChoiceId FROM MySurvey_Responses", connection);

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

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

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

VB.NET

Dim connectionString As String = "InitiateOAuth=GETANDREFRESH;OAuthClientId=MyOAuthClientId;OAuthClientSecret=MyOAuthClientSecret;CallbackURL=http://localhost:portNumber;"

Using connection As New SurveyMonkeyConnection(connectionString)
  Dim dataAdapter As New SurveyMonkeyDataAdapter("SELECT RespondentId, ChoiceId FROM MySurvey_Responses", connection)

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

  Console.WriteLine("Contents of MySurvey_Responses.")

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

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