ADO.NET Provider for Sage 200

Build 23.0.8839

DataAdapter を使用したクエリ

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

Sage200DataAdapter の使用

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

次の例は、Banks テーブルのId カラムとCode カラムを選択します。

C#

string connectionString = "InitiateOAuth=GETANDREFRESH;SubscriptionKey=12345;Schema=StandardUK";

using (Sage200Connection connection = new Sage200Connection(connectionString)) {
  Sage200DataAdapter dataAdapter = new Sage200DataAdapter(
  "SELECT Id, Code FROM Banks", connection);

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

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

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

VB.NET

Dim connectionString As String = "InitiateOAuth=GETANDREFRESH;SubscriptionKey=12345;Schema=StandardUK"

Using connection As New Sage200Connection(connectionString)
  Dim dataAdapter As New Sage200DataAdapter("SELECT Id, Code FROM Banks", connection)

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

  Console.WriteLine("Contents of Banks.")

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

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