Users can connect to a cube database through ConnectCube method. This method accepts two parameters: the name of the cube and the connection string to the installed SSAS.
The connection string must specify the Data Source, that is the Server name, and the Initial Catalog, that is the database name. The version of the Provider must also be specified if more than one Microsoft OLE DB provider for FlexPivot is installed. For instance, if the Provider is set to MSOLAP, the latest version of OLE DB for FlexPivot installed on your system is used.
The code given below illustrates an example of connecting to a cube.
C# |
Copy Code
|
---|---|
private void Window_Loaded(object sender, RoutedEventArgs e) { //prepare to build view string connectionString = @"Data Source=http://ssrs.componentone.com/OLAP/msmdpump.dll;Provider=msolap;Initial Catalog=AdventureWorksDW2012Multidimensional"; string cubeName = "Adventure Works"; try { flexPivotPage.FlexPivotPanel.ConnectCube(cubeName, connectionString); // show some data. var fp = flexPivotPage.FlexPivotEngine; fp.BeginUpdate(); fp.ColumnFields.Add("Color"); fp.RowFields.Add("Category"); fp.ValueFields.Add("Order Count"); fp.EndUpdate(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } |