ADO.NET Provider for MYOB

Build 23.0.8839

DataReader を使用したクエリ

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

MYOBDataReader の使用

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

C#

string connectionString = " If using an online instance: InitiateOAuth=GETANDREFRESH;OAuthClientId=YourClientId;OAuthClientSecret=YourClientSecret;CompanyFileId=yourCompanyFileId;CallbackURL=http://localhost:33333;User=companyFileUser;Password=companyFilePassword; If using an on premise instance: InitiateOAuth=OFF;URL=http://localhost:8080/accountright;CompanyFileId=327eed10-9615-4e5e-bd9e-ae2cc00e2c70;User=companyFileUser;Password=companyFilePassword;";

using (MYOBConnection connection = new MYOBConnection(connectionString)) {
  MYOBCommand cmd = new MYOBCommand("SELECT * FROM Accounts", connection);
  
  MYOBDataReader 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 = " If using an online instance: InitiateOAuth=GETANDREFRESH;OAuthClientId=YourClientId;OAuthClientSecret=YourClientSecret;CompanyFileId=yourCompanyFileId;CallbackURL=http://localhost:33333;User=companyFileUser;Password=companyFilePassword; If using an on premise instance: InitiateOAuth=OFF;URL=http://localhost:8080/accountright;CompanyFileId=327eed10-9615-4e5e-bd9e-ae2cc00e2c70;User=companyFileUser;Password=companyFilePassword;"

Using connection As New MYOBConnection(connectionString)
  Dim cmd As New MYOBCommand("SELECT * FROM Accounts", connection)

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