wpf-devexpress-dot-xpf-dot-pivotgrid-dot-pivotgridcontrol-7948d219.md
Gets or sets a connection string to a cube in an MS Analysis Services database.
Namespace : DevExpress.Xpf.PivotGrid
Assembly : DevExpress.Xpf.PivotGrid.v25.2.dll
NuGet Package : DevExpress.Wpf.PivotGrid
public string OlapConnectionString { get; set; }
Public Property OlapConnectionString As String
| Type | Description |
|---|---|
| String |
A String that specifies a connection string to a cube in an MS Analysis Services database.
|
To retrieve data from an OLAP cube asynchronously, use the PivotGridControl.SetOlapConnectionStringAsync method to specify a connection string.
A sample connection string is shown below:
OlapConnectionString=”Provider=msolap;Data Source=localhost;Initial Catalog=Adventure Works DW;Cube Name=Adventure Works;Query Timeout=100;”
The connection string has the following parameters:
Provider - Identifies a data provider to be used. The “msolap” string identifies the latest version of Microsoft SQL Server Analysis Services (SSAS);
Data Source - Specifies the name of a server that runs an instance of SSAS;
Initial Catalog - Specifies a data catalog that contains cubes;
Cube Name - Specifies the name of a cube that provides OLAP data;
Query Timeout (optional) - The maximum amount of time, in seconds, to wait for a query to SSAS to complete. If the parameter is set to 0, each query can last indefinitly.
Imports System.Windows
Imports DevExpress.Xpf.PivotGrid
Namespace HowToBindOLAP
''' <summary>
''' Interaction logic for MainWindow.xaml
''' </summary>
Partial Public Class MainWindow
Inherits Window
Public Sub New()
InitializeComponent()
End Sub
Private Sub Window_Loaded(ByVal sender As Object, ByVal e As RoutedEventArgs)
pivotGridControl1.OlapConnectionString = "Provider=msolap;" & "Data Source=http://demos.devexpress.com/Services/OLAP/msmdpump.dll;" & "Initial Catalog=Adventure Works DW Standard Edition;" & "Cube Name=Adventure Works;"
pivotGridControl1.BeginUpdate()
' Create Pivot Grid fields.
Dim fieldMeasuresInternetSalesAmount As New PivotGridField()
fieldMeasuresInternetSalesAmount.Caption = "Internet Sales Amount"
fieldMeasuresInternetSalesAmount.Area = FieldArea.DataArea
pivotGridControl1.Fields.Add(fieldMeasuresInternetSalesAmount)
Dim fieldSales As New PivotGridField()
fieldSales.Caption = "Cleared Amount"
fieldSales.Area = FieldArea.DataArea
fieldSales.CellFormat = "c"
pivotGridControl1.Fields.Add(fieldSales)
' Populate fields with data.
fieldMeasuresInternetSalesAmount.DataBinding = New DataSourceColumnBinding("[Measures].[Internet Sales Amount]")
fieldSales.DataBinding = New OlapExpressionBinding("[Measures].[Internet Sales Amount] * 0.87")
AddField("Country", FieldArea.RowArea, "[Customer].[Country].[Country]", 0)
AddField("Fiscal Year", FieldArea.ColumnArea, "[Date].[Fiscal Year].[Fiscal Year]", 0)
pivotGridControl1.EndUpdate()
End Sub
Private Function AddField(ByVal caption As String, ByVal area As FieldArea, ByVal fieldName As String, ByVal index As Integer) As PivotGridField
Dim field As PivotGridField = pivotGridControl1.Fields.Add()
field.Caption = caption
field.Area = area
If fieldName <> String.Empty Then
field.DataBinding = New DataSourceColumnBinding(fieldName)
End If
field.AreaIndex = index
Return field
End Function
End Class
End Namespace
using DevExpress.Xpf.PivotGrid;
using System.Windows;
namespace HowToBindOLAP {
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window {
public MainWindow() {
InitializeComponent();
}
private void Window_Loaded(object sender, RoutedEventArgs e) {
pivotGridControl1.OlapConnectionString = "Provider=msolap;" +
"Data Source=http://demos.devexpress.com/Services/OLAP/msmdpump.dll;" +
"Initial Catalog=Adventure Works DW Standard Edition;" +
"Cube Name=Adventure Works;";
pivotGridControl1.BeginUpdate();
// Create Pivot Grid fields.
PivotGridField fieldMeasuresInternetSalesAmount =
new PivotGridField();
fieldMeasuresInternetSalesAmount.Caption = "Internet Sales Amount";
fieldMeasuresInternetSalesAmount.Area = FieldArea.DataArea;
pivotGridControl1.Fields.Add(fieldMeasuresInternetSalesAmount);
PivotGridField fieldSales = new PivotGridField();
fieldSales.Caption = "Cleared Amount";
fieldSales.Area = FieldArea.DataArea;
fieldSales.CellFormat = "c";
pivotGridControl1.Fields.Add(fieldSales);
// Populate fields with data.
fieldMeasuresInternetSalesAmount.DataBinding =
new DataSourceColumnBinding("[Measures].[Internet Sales Amount]");
fieldSales.DataBinding =
new OlapExpressionBinding("[Measures].[Internet Sales Amount] * 0.87");
AddField("Country", FieldArea.RowArea, "[Customer].[Country].[Country]", 0);
AddField("Fiscal Year", FieldArea.ColumnArea, "[Date].[Fiscal Year].[Fiscal Year]", 0);
pivotGridControl1.EndUpdate();
}
// Add fields to the Pivot Grid and bind them to data.
private PivotGridField AddField(string caption, FieldArea area, string fieldName, int index) {
PivotGridField field = pivotGridControl1.Fields.Add();
field.Caption = caption;
field.Area = area;
if (fieldName != string.Empty)
field.DataBinding = new DataSourceColumnBinding(fieldName);
field.AreaIndex = index;
return field;
}
}
}
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:HowToBindOLAP"
xmlns:dxpg="http://schemas.devexpress.com/winfx/2008/xaml/pivotgrid" x:Class="HowToBindOLAP.MainWindow"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800" Loaded="Window_Loaded">
<Grid>
<dxpg:PivotGridControl Name="pivotGridControl1"/>
</Grid>
</Window>
The following code snippets (auto-collected from DevExpress Examples) contain references to the OlapConnectionString property.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.
wpf-pivot-grid-connect-to-an-olap-datasource/CS/WpfOlapRetrieveFieldsExample/MainWindow.xaml#L20
OlapDataProvider="Adomd"
OlapConnectionString="{Binding ConnectionString, Source={StaticResource PivotOlapDataSource}}" />
</Grid>
wpf-pivot-grid-bind-to-an-olap-cube-net6/CS/HowToBindOLAP/MainWindow.xaml.cs#L13
private void Window_Loaded(object sender, RoutedEventArgs e) {
pivotGridControl1.OlapConnectionString = "Provider=msolap;" +
"Data Source=http://demos.devexpress.com/Services/OLAP/msmdpump.dll;" +
wpf-pivot-grid-bind-to-an-olap-cube-net6/VB/HowToBindOLAP/MainWindow.xaml.vb#L16
Private Sub Window_Loaded(ByVal sender As Object, ByVal e As RoutedEventArgs)
pivotGridControl1.OlapConnectionString = "Provider=msolap;" & "Data Source=http://demos.devexpress.com/Services/OLAP/msmdpump.dll;" & "Initial Catalog=Adventure Works DW Standard Edition;" & "Cube Name=Adventure Works;"
pivotGridControl1.BeginUpdate()
See Also