using
Microsoft.AnalysisServices.AdomdClient;
Using System;
Using System.Data;
Using Microsoft.AnalysisServices.AdomdClient;
class
Program{
static
void
Main (
string
[] args) {
AdomdConnection conn =
new
AdomdConnection(
"Data Source=localhost;Catalog=Adventure Works DW Standard Edition"
);
conn.Open( );
commandText =
"SELECT {[Measures].[Sales Amount], "
+
"[Measures].[Gross Profit Margin]} ON COLUMNS, "
"{[Product].[Product Model Categories].[Category]} ON ROWS "
"FROM [Adventure Works] "
"WHERE ([Sales Territory Country].[United States])"
;
AdomdCommand cmd =
AdomdCommand(commandText, conn);
AdomdDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
// output the rows in the DataReader
while
(dr.Read( )) {
for
(
int
i = 0; i < dr.FieldCount; i++)
Console.Write(dr[i] + (i == dr.FieldCount - 1 ?
""
:
", "
));
Console.WriteLine( );
}
dr.Close( );
Console.WriteLine(Environment.NewLine +
"Press any key to continue."
Console.ReadKey( );
Back to top