ComponentOne FlexPivot for WinForms
Connecting to a Cube
FlexPivot Cube > Connecting to a Cube

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.

Copy Code
'prepare to build view
Dim connectionString As String = "Data Source=ServerAddress;Provider=msolap;Initial Catalog=DatabaseName;User Id=ValidUserID; Password=ValidPassword"

Dim cubeName As String = "Adventure Works"
Try
c1FlexPivotPage1.FlexPivotPanel.ConnectCube(cubeName, connectionString)
' show some data.
Dim fp = c1FlexPivotPage1.FlexPivotEngine
fp.BeginUpdate()
fp.ColumnFields.Add("Color")
fp.RowFields.Add("Category")
fp.ValueFields.Add("Order Count")
fp.EndUpdate()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
Copy Code
//prepare to build view
string connectionString = @"Data Source=ServerAddress;Provider=msolap;Initial Catalog=DatabaseName;User Id=ValidUserID; Password=ValidPassword";

string cubeName = "Adventure Works";
try
{
c1FlexPivotPage1.FlexPivotPanel.ConnectCube(cubeName, connectionString);
// show some data.
var fp = c1FlexPivotPage1.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);
}