ADO.NET Provider for Reckon

Build 23.0.8843

DataAdapter を使用したクエリ

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

ReckonDataAdapter の使用

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

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

C#

string connectionString = "User=test;Password=test;URL=http://localhost:8166;";

using (ReckonConnection connection = new ReckonConnection(connectionString)) {
  ReckonDataAdapter dataAdapter = new ReckonDataAdapter(
  "SELECT Id, Name FROM Customers", connection);

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

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

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

VB.NET

Dim connectionString As String = "User=test;Password=test;URL=http://localhost:8166;"

Using connection As New ReckonConnection(connectionString)
  Dim dataAdapter As New ReckonDataAdapter("SELECT Id, Name FROM Customers", connection)

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

  Console.WriteLine("Contents of Customers.")

  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.8843