Search code examples
c#excelolap-cubepowerpivotdatamodel

Made connection to PowerPivot DataModel, how can I fill a dataset with it?


I was able to connect to the powerpivot datamodel with amo:

string ConnString = 
       "Provider=MSOLAP;Data Source=$Embedded$;
       Locale Identifier=1033;Location=" + ThisAddIn.Current.Application.
       ActiveWorkbook.FullName + ";SQLQueryMode=DataKeys";

Microsoft.AnalysisServices.Server OlapServer = 
                                        new Microsoft.AnalysisServices.Server();

and I am able to retrieve the column names but nothing else. How can I fill a dataset from the model or even how can I view the cell values within this datamodel? I have attempted this

AdomdConnection Conn = new AdomdConnection(ConnString);//using the above string
Conn.Open();
command = new AdomdCommand("SELECT [Table1].[x] ON COLUMNS FROM [Model]",Conn);
adapter = new AdomdDataAdapter(command);
adapter.Fill(dataset);

but all that shows up is the number 1 as the contents no matter what is in the datamodel.


Solution

  • Using a DAX query instead of a MDX query solved the problem.