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

狂风中的少年 提交于 2020-01-17 12:50:10

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/24763513/made-connection-to-powerpivot-datamodel-how-can-i-fill-a-dataset-with-it

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!