How to use DMX query by ADOMD.NET

1k views Asked by At

I have built a Analysis Services and apply Data Mining by Bussness Intelligent Development Studio. Now i have a prediction query as the follows:

SELECT
  PredictAssociation([Association].[v User Subscribe Product], INCLUDE_STATISTICS, 3)
From
  [Association]
NATURAL PREDICTION JOIN
(SELECT (SELECT 'Ipad 1' AS [Product Name]
  UNION SELECT 'Ipad 2' AS [Product Name]
  UNION SELECT 'Iphone 3GS' AS [Product Name]
  UNION SELECT 'Iphone 5C' AS [Product Name]) AS [v User Subscribe Product]) AS t

And my result view in SQL Management Studio as the follows:

enter image description here

I using ADOMD.NET to get the READER the show on my application. My code as the belows:

var command = new AdomdCommand(DMXQuery, SqlConnectionHelper.GetConnectionSSAS());
var reader = command.ExecuteReader();

Every things is going to be ok. Reader execute still ok. But i don't know how to get "PRODUCT NAME" exactly. Reader included it, but i dont know how to get.

Does is anybody know this?

Tks for advance.

1

There are 1 answers

0
Andrey Ershov On
while (reader.Read())
{
    Console.Write(reader[0]); // Your product name

    // Other fields
    for (int i = 1; i < reader.FieldCount; i++)
    {
        Console.Write(reader[i] + " ");
    }

    Console.WriteLine();
}
reader.Close();