ADO.NET Provider for Microsoft SQL Server Analysis Services

Build 23.0.8839

DataAdapter を使用したクエリ

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

SSASDataAdapter の使用

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

次の例は、Customer テーブルのCountry カラムとEducation カラムを選択します。

C#

string connectionString = "User=myuseraccount;Password=mypassword;URL=http://localhost/OLAP/msmdpump.dll;";

using (SSASConnection connection = new SSASConnection(connectionString)) {
  SSASDataAdapter dataAdapter = new SSASDataAdapter(
  "SELECT Country, Education FROM [AdventureWorksDW2012Multidimensional-SE].[Adventure Works].Customer", connection);

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

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

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

VB.NET

Dim connectionString As String = "User=myuseraccount;Password=mypassword;URL=http://localhost/OLAP/msmdpump.dll;"

Using connection As New SSASConnection(connectionString)
  Dim dataAdapter As New SSASDataAdapter("SELECT Country, Education FROM [AdventureWorksDW2012Multidimensional-SE].[Adventure Works].Customer", connection)

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

  Console.WriteLine("Contents of Customer.")

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

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