ADO.NET Provider for PingOne

Build 25.0.9434

DataAdapter を使用したクエリ

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

PingOneDataAdapter の使用

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

次の例は、Users テーブルのUsername カラムとEmail カラムを選択します。

C#

string connectionString = "AuthScheme=OAuth;InitiateOAuth=GETANDREFRESH;WorkerAppEnvironmentId=eebc33a8-xxxx-4f3a-yyyy-d3e5262fd49e;Region=NA;OAuthClientId=client_id;OAuthClientSecret=client_secret;";

using (PingOneConnection connection = new PingOneConnection(connectionString)) {
  PingOneDataAdapter dataAdapter = new PingOneDataAdapter(
  "SELECT Username, Email FROM [CData].[Administrators].Users", connection);

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

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

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

VB.NET

Dim connectionString As String = "AuthScheme=OAuth;InitiateOAuth=GETANDREFRESH;WorkerAppEnvironmentId=eebc33a8-xxxx-4f3a-yyyy-d3e5262fd49e;Region=NA;OAuthClientId=client_id;OAuthClientSecret=client_secret;"

Using connection As New PingOneConnection(connectionString)
  Dim dataAdapter As New PingOneDataAdapter("SELECT Username, Email FROM [CData].[Administrators].Users", connection)

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

  Console.WriteLine("Contents of Users.")

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

Copyright (c) 2025 CData Software, Inc. - All rights reserved.
Build 25.0.9434