ADO.NET Provider for Autify

Build 23.0.8839

DataAdapter を使用したクエリ

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

AutifyDataAdapter の使用

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

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

C#

string connectionString = "ProjectId=255;ApiKey=M9e88D3s31b35347EgNVa;";

using (AutifyConnection connection = new AutifyConnection(connectionString)) {
  AutifyDataAdapter dataAdapter = new AutifyDataAdapter(
  "SELECT Name, ProjectURL FROM Scenarios", connection);

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

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

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

VB.NET

Dim connectionString As String = "ProjectId=255;ApiKey=M9e88D3s31b35347EgNVa;"

Using connection As New AutifyConnection(connectionString)
  Dim dataAdapter As New AutifyDataAdapter("SELECT Name, ProjectURL FROM Scenarios", connection)

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

  Console.WriteLine("Contents of Scenarios.")

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

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