ADO.NET Provider for Act-On

Build 23.0.8839

DataReader を使用したクエリ

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

ActOnDataReader の使用

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

C#

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

using (ActOnConnection connection = new ActOnConnection(connectionString)) {
  ActOnCommand cmd = new ActOnCommand("SELECT * FROM Images", connection);
  
  ActOnDataReader rdr = cmd.ExecuteReader();

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

VB.NET

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

Using connection As New ActOnConnection(connectionString)
  Dim cmd As New ActOnCommand("SELECT * FROM Images", connection)

  Dim rdr As ActOnDataReader = cmd.ExecuteReader()

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

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