# Connecting to a Cube

This topic covers information about connecting to data processing units like Cube.

## Content

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.

```vbnet
'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
FlexPivotPage1.FlexPivotPanel.ConnectCube(cubeName, connectionString)
' show some data.
Dim fp = FlexPivotPage1.PivotEngine
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
```

```csharp
//prepare to build view
string connectionString = @"Data Source=ServerAddress;Provider=msolap;Initial Catalog=DatabaseName;User Id=ValidUserID; Password=ValidPassword";
string cubeName = "Adventure Works";
try
{
FlexPivotPage1.FlexPivotPanel.ConnectCube(cubeName, connectionString);
// show some data.
var fp = FlexPivotPage1.PivotEngine;
fp.BeginUpdate();
fp.ColumnFields.Add("Color");
fp.RowFields.Add("Category");
fp.ValueFields.Add("Order Count");
fp.EndUpdate();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
```