ADO.NET Provider for Money Forward Expense

Build 23.0.8839

DataReader を使用したクエリ

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

MFExpenseDataReader の使用

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

C#

string connectionString = "InitiateOAuth=GETANDREFRESH;OAuthClientId=MyOAuthClientId;OAuthClientSecret=MyOAuthClientSecret;CallbackURL=https://oauth.cdata.com/oauth/";

using (MFExpenseConnection connection = new MFExpenseConnection(connectionString)) {
  MFExpenseCommand cmd = new MFExpenseCommand("SELECT * FROM Offices", connection);
  
  MFExpenseDataReader 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=https://oauth.cdata.com/oauth/"

Using connection As New MFExpenseConnection(connectionString)
  Dim cmd As New MFExpenseCommand("SELECT * FROM Offices", connection)

  Dim rdr As MFExpenseDataReader = 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