ADO.NET Provider for Highrise

Build 23.0.8839

DataReader を使用したクエリ

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

HighriseDataReader の使用

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

C#

string connectionString = "InitiateOAuth=GETANDREFRESH;OAuthClientId=MyClientId;OAuthClientSecret=MyClientSecret;CallbackURL=http://localhost;AccountId=MyAccountId;";

using (HighriseConnection connection = new HighriseConnection(connectionString)) {
  HighriseCommand cmd = new HighriseCommand("SELECT * FROM People", connection);
  
  HighriseDataReader rdr = cmd.ExecuteReader();

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

VB.NET

Dim connectionString As String = "InitiateOAuth=GETANDREFRESH;OAuthClientId=MyClientId;OAuthClientSecret=MyClientSecret;CallbackURL=http://localhost;AccountId=MyAccountId;"

Using connection As New HighriseConnection(connectionString)
  Dim cmd As New HighriseCommand("SELECT * FROM People", connection)

  Dim rdr As HighriseDataReader = cmd.ExecuteReader()

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

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