ADO.NET Provider for Sage 300

Build 23.0.8839

DataAdapter を使用したクエリ

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

Sage300DataAdapter の使用

アダプターのFill メソッドを使用して、データソースからデータを取得します。空のDataTable インスタンスがFill メソッドへの引数として渡されます。このメソッドが戻ってきたとき、DataTable インスタンスにはクエリされたデータが設定されています。Fill メソッドは、戻る前にデータソースからすべてのデータを取得する必要があるため、Sage300DataAdapter はSage300DataReader よりも時間がかかります。

次の例は、OEInvoices テーブルのInvoiceUniquifier カラムとApprovedLimit カラムを選択します。

C#

string connectionString = "User=SAMPLE;Password=password;URL=http://127.0.0.1/Sage300WebApi/v1/-/;Company=SAMINC;";

using (Sage300Connection connection = new Sage300Connection(connectionString)) {
  Sage300DataAdapter dataAdapter = new Sage300DataAdapter(
  "SELECT InvoiceUniquifier, ApprovedLimit FROM OEInvoices", connection);

  DataTable table = new DataTable();
  dataAdapter.Fill(table);

  Console.WriteLine("Contents of OEInvoices.");

  foreach (DataRow row in table.Rows) {
    Console.WriteLine("{0}: {1}", row["InvoiceUniquifier"], row["ApprovedLimit"]);
  }
}

VB.NET

Dim connectionString As String = "User=SAMPLE;Password=password;URL=http://127.0.0.1/Sage300WebApi/v1/-/;Company=SAMINC;"

Using connection As New Sage300Connection(connectionString)
  Dim dataAdapter As New Sage300DataAdapter("SELECT InvoiceUniquifier, ApprovedLimit FROM OEInvoices", connection)

  Dim table As New DataTable()
  dataAdapter.Fill(table)

  Console.WriteLine("Contents of OEInvoices.")

  For Each row As DataRow In table.Rows
    Console.WriteLine("{0}: {1}", row("InvoiceUniquifier"), row("ApprovedLimit"))
  Next
End Using

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