ADO.NET Provider for Microsoft Office 365

Build 23.0.8839

DataReader を使用したクエリ

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

Office365DataReader の使用

Office365DataReader はページ単位でデータを取得できるため、Office365DataAdapter よりもデータの取得が高速です。Office365DataReader からデータを読み取っていくと、必要に応じて一定の間隔で、データソースからの結果の次のページが要求されます。このため、結果が高速に返されます。 次の例は、Events テーブルからすべてのカラムを選択します。

C#

string connectionString = "InitiateOAuth=GETANDREFRESH;OAuthClientId=MyApplicationId;OAuthClientSecret=MySecretKey;CallbackURL=http://localhost:33333;";

using (Office365Connection connection = new Office365Connection(connectionString)) {
  Office365Command cmd = new Office365Command("SELECT * FROM Events", connection);
  
  Office365DataReader rdr = cmd.ExecuteReader();

  while (rdr.Read()) {
    Console.WriteLine(String.Format("\t{0} --> \t\t{1}", rdr["Id"], rdr["location_displayName"]));
  }
}

VB.NET

Dim connectionString As String = "InitiateOAuth=GETANDREFRESH;OAuthClientId=MyApplicationId;OAuthClientSecret=MySecretKey;CallbackURL=http://localhost:33333;"

Using connection As New Office365Connection(connectionString)
  Dim cmd As New Office365Command("SELECT * FROM Events", connection)

  Dim rdr As Office365DataReader = cmd.ExecuteReader()

  While rdr.Read()
    Console.WriteLine([String].Format(vbTab & "{0} --> " & vbTab & vbTab & "{1}", rdr("Id"), rdr("location_displayName")))
  End While
End Using

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