Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
65
create AdomdDataSource datasource in code
posted

Hi,

 

I've just started using the xamlPivotGrid and the adomdDatasource and I can configure the datasource correctly in xaml but if I try to create it in code I ran into some trouble. I couldn't find a code sample (only zaml) that shows how to configure the datasource in the code -behind. Do you have one that I could modify and add in my application?

I need one that will connect to an olap cube and preset a query (measures, columns and rows)

Thanks.

 

Parents
No Data
Reply
  • 7922
    Verified Answer
    posted

    Hi,

    You can use the sample below

     

    AdomdConnectionSettings connectionSettings = new AdomdConnectionSettings();

    connectionSettings.ConnectionString = "Provider=MSOLAP.3;Integrated Security=SSPI;Persist Security Info=True;Initial Catalog=Adventure Works DW 2008;Data Source=local;MDX Compatibility=1;Safety Options=2;MDX Missing Member Mode=Error";

              

    AdomdDataSource xmlaDataSource = new AdomdDataSource(xmlaDataProvider)

    {

        ConnectionSettings= connectionSettings,

        Database = DataSourceBase.GenerateInitialDatabase("Adventure Works DW 2008"),

        Cube = DataSourceBase.GenerateInitialCube("Adventure Works"),

        Columns = DataSourceBase.GenerateInitialItems("[Columns]"),

        Rows = DataSourceBase.GenerateInitialItems("[Products],[Drivers]"),

        Measures = DataSourceBase.GenerateInitialItems("Value1,Value2,ROI")

    };

     

    Regards

    Todor

     

Children