ADO.NET Provider for Bugzilla

Build 23.0.8839

DataAdapter を使用したクエリ

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

BugzillaDataAdapter の使用

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

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

C#

string connectionString = " Url=http://<yourdomainname>/Bugzilla;APIKey=abc123;";

using (BugzillaConnection connection = new BugzillaConnection(connectionString)) {
  BugzillaDataAdapter dataAdapter = new BugzillaDataAdapter(
  "SELECT Id, Column1 FROM SampleTable_1", connection);

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

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

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

VB.NET

Dim connectionString As String = " Url=http://<yourdomainname>/Bugzilla;APIKey=abc123;"

Using connection As New BugzillaConnection(connectionString)
  Dim dataAdapter As New BugzillaDataAdapter("SELECT Id, Column1 FROM SampleTable_1", connection)

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

  Console.WriteLine("Contents of SampleTable_1.")

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

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