Microsoft OLE DB for OLAP Sample Applications

January 1998

Abstract

This document provides information for Microsoft® OLE DB for OLAP Sample Applications.

Overview

The sample OLAP applications included with the OLE DB for OLAP SDK are all client applications. These samples are generic and should work with any multidimensional data provider exposing OLE DB for OLAP interfaces. A sample OLAP multidimensional database (BobsVideo.cub) is included with these samples and accessed via the Microsoft PivotTable Service provider installed with the SDK components.

BobsVideo.cub is a prebuilt cube representing the store sales for a fictitious video store. The source relational data this cube was built from using the Microsoft PivotTable Service provider is also included as VideoStore.mdb for reference.

Microsoft OLEDB for OLAP Sample Applications

OLEDB4OLAPdemo

This console application submits schema rowset commands and MDX statements to an OLAP cube database. The path and name of the cube database file as well as the query file must be specified on the command line. The application opens a connection to the specified cube using the MSOLAP Sample OLAP provider. The query file must be a text file and can be edited with any text editor such as Notepad. Each line contains either a schema rowset command or a MDX statement. The file is opened by the application and each line is submitted to the MSOLAP provider. The output from these commands is logged to a text file. The output file is created using the query file's name with a ".log" extension. This log file is generated in the same directory in which the original cube file exists.

MDX Statements begin with the word SELECT, while schema commands begin with the word SCHEMA. Schema rowset commands starting with the word "Schema" are followed by several parameters delimited by spaces. Parameters are specified with the syntax: Identifier=Value. If the Value contains spaces, it must be enclosed with quotes. The first parameter specifies the desired schema rowset (Cubes, Dimensions, Levels, etc.). Below is an example of parameters specifying the desired restrictions for the sample data cube (BobsVideo.cub).

SCHEMA Rowset=Dimensions Cube_Name="Bobs Video Store" Dimension_Name="Customer Location"

A query file named "BobsVideo.mdx" is included with OLEDB4OLAPdemo. This file contains schema rowset commands and MDX statements pertaining to the sample cube.

Note: For the set of possible restriction identifiers for each schema rowset, please refer to the "Session Object" section in the OLE DB for OLAP Programmer’s Reference. An explanation of MDX syntax can be found in this reference as well.

OLEDB4OLAPdemo usage is as follows:

C:> OleDb4Olap  "Cube File Name"  "Query File Name"

"Cube File Name" is the name and path of the cube database file and "Query File Name" is the name and path of the file containing the schema rowset commands and/or MDX query statements.

DatasetViewer

This windows application is a generic OLE DB client. The DatasetViewer consists of MDI child windows. Each child represents a connection to an OLE DB provider. The child window contains three parts: At the top is a query window where SQL or MDX statements can be entered; A rowset list view where rowset data s displayed; At the bottom is a list box containing information on all OLE DB interface calls made by the application.

It is possible to connect to any OLE DB provider including an OLE DB for OLAP provider. The "Full Connect" dialog enumerates all OLE DB providers presently installed and registered. The sample OLAP provider, MSOLAP, appears in the drop down list of enumerated providers.

To connect to the sample cube database:

  1. Select MSOLAP from the provider list.

  2. Enter the name and path to the BobsVideo.cub file in the Location edit box.

The Location edit box corresponds to the DBPROP_INIT_LOCATION property for the selected provider.

Once the connection has been established, it is possible to browse the OLAP schema information by selecting the Session menu's IDBSchemaRowset->GetRowset menu item. The IDBSchemaRowset dialog provides a drop down list of all the schema rowsets provided by the currently connected data source. Once a schema rowset has been selected from this list, it is possible to restrict the rowset by specifying any, or several, of the restriction options appearing in the dialog. After clicking the OK button, the schema rowset data is displayed in the rowset list view.

To enter an MDX query statement:

  1. Type the query into the query window.

  2. Select either of the Command's menu ICommand->ExecuteRowset or ICommand->ExecuteDataset menu items.

The ExecuteRowset menu will create a flattened dataset and display the rows in the Rowset list view. The ExecuteDataset will create a dataset.

To display the dataset:

  1. Select one of the menu items from the Dataset menu. If the IMDDataset->GetAxisRowset menu item is selected; it provides a dialog to choose the axis from a drop down list of axes that pertain to the MDX query.

  2. Select the OK button to display the axis rowset in the rowset list view.

If the IMDDataset->GetDataSet menu item is selected; it will display the cube data in the rowset list view as a linear list of cube cells. The data and the cell ordinal are displayed for each cell in the list view.

If the IMDDataset->GetAxisInfo menu item is selected; a dialog containing the MDAXISINFO data returned by the OLAP provider is displayed.

MDXSample

This generic OLE DB for OLAP client application, written in Visual Basic®, uses ADO MD to obtain schema information and query a multidimensional data source. The application consists of a query window to enter MDX queries and a schema window where schema information is presented in a tree view as well as a dataset grid where query data is displayed in a pivot table.

To connect to the sample OLAP provider:

  1. Specify the MSOLAP provider in the initial connect dialog.

  2. Enter the name and path to the sample cube database (BobsVideo.cub).

To enter or edit a sample query:

  1. Use Open from the File menu to open the MDXQuery.mdx sample query file.

  2. Select a sample query from the Queries box on the toolbar.

MDXSamples.mdx is a text file which contains several MDX queries designed for the sample cube database file, BobsVideo.cub. New queries can be entered and saved as well.

Fully commented Visual Basic source code for the MDX Sample Application can be viewed by opening the MDXSampl.vbp project file in Visual Basic. The frmMain.frm or Main.frm file contains sample code. A search on "ADO" provides specific information and comments on how ADO MD is used by this application. These commented code examples are useful for creating a new MDX querying application.