ADO.NET Provider for Kingdee K3 WISE

Build 23.0.8839

DataAdapter を使用したクエリ

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

KingdeeK3WISEDataAdapter の使用

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

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

C#

string connectionString = "User=myuseraccount;Password=mypassword;URL=http://ip;AccountId=myaccountid;";

using (KingdeeK3WISEConnection connection = new KingdeeK3WISEConnection(connectionString)) {
  KingdeeK3WISEDataAdapter dataAdapter = new KingdeeK3WISEDataAdapter(
  "SELECT Id, Name FROM Account", connection);

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

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

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

VB.NET

Dim connectionString As String = "User=myuseraccount;Password=mypassword;URL=http://ip;AccountId=myaccountid;"

Using connection As New KingdeeK3WISEConnection(connectionString)
  Dim dataAdapter As New KingdeeK3WISEDataAdapter("SELECT Id, Name FROM Account", connection)

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

  Console.WriteLine("Contents of Account.")

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

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