ADO.NET Provider for PCA Sales

Build 23.0.8839

DataAdapter を使用したクエリ

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

PCASalesDataAdapter の使用

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

次の例は、MasterSms テーブルのSyohinCode カラムとSyohinMei カラムを選択します。

C#

string connectionString = "InitiateOAuth=GETANDREFRESH;DefaultDataArea=P20V01C081KON0002;DataCenter=east02;";

using (PCASalesConnection connection = new PCASalesConnection(connectionString)) {
  PCASalesDataAdapter dataAdapter = new PCASalesDataAdapter(
  "SELECT SyohinCode, SyohinMei FROM MasterSms", connection);

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

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

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

VB.NET

Dim connectionString As String = "InitiateOAuth=GETANDREFRESH;DefaultDataArea=P20V01C081KON0002;DataCenter=east02;"

Using connection As New PCASalesConnection(connectionString)
  Dim dataAdapter As New PCASalesDataAdapter("SELECT SyohinCode, SyohinMei FROM MasterSms", connection)

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

  Console.WriteLine("Contents of MasterSms.")

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

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