ADO.NET Provider for Microsoft Bing

Build 23.0.8839

DataAdapter を使用したクエリ

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

BingDataAdapter の使用

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

次の例は、WebSearch テーブルのURL カラムとTitle カラムを選択します。

C#

string connectionString = "APIKey=abc123;";

using (BingConnection connection = new BingConnection(connectionString)) {
  BingDataAdapter dataAdapter = new BingDataAdapter(
  "SELECT URL, Title FROM WebSearch WHERE SearchTerms = 'Microsoft'", connection);

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

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

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

VB.NET

Dim connectionString As String = "APIKey=abc123;"

Using connection As New BingConnection(connectionString)
  Dim dataAdapter As New BingDataAdapter("SELECT URL, Title FROM WebSearch WHERE SearchTerms = 'Microsoft'", connection)

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

  Console.WriteLine("Contents of WebSearch.")

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

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