|
|
|
|
||||||||||
| The Local Cube Information Center |
www.cubeslice.com |
||||||||||||
|
|
|||||||||||||
Creating a Local Cube in Visual BasicNote: The code samples here work for SQL Server 2000. They will not work for SQL Server 2005. To create a local cube in SQL Server 2005 from an Analysis Server cube you must use the CREATE GLOBAL CUBE statement or use the Analysis Services Scripting Language (ASSL). |
|||||||||||||
|
The ADO MD object library is used to create a SQL Server 2000 local cube in Visual Basic. Add the Microsoft ActiveX Data Object (Multidimensional) Library to your project. The following four strings are used together in a connection string to create a local cube with ADO MD: |
|
||||||||||||
|
After you assign the combined value of the strings to the ConnectionString property, you simply issue an Open command on the Connection object, and the local cube is created. The Location The local file Location string contains the full path and file name of the local cube that is going to be created: LOCATION= C:\Temp\20010320LocalCube.cub The Source DSN The source DSN contains a reference to the provider, data source, and the initial catalog. To create a cube from the sample FoodMart database located in Analysis Services on the local machine, you could use a source DSN like this: SOURCE_DSN="Provider=MSOLAP;data source=LocalHost;INITIAL CATALOG=FoodMart 2000" The Create Cube Statement You specify each of the cube's dimensions, hierarchies, levels, member properties, measures, and calculated members in the Create Cube statement. Here's a sample of a Create Cube statement: CREATECUBE=CREATE CUBE LocalCube The Insert Into Statement The Insert Into statement has two clauses. The first clause specifies the specific cube structures that you are inserting into. The second clause is a Select statement that must provide a value for each of those structures. You must provide a value for each level and member property that you have specified in the Create Cube statement. As the following example shows, you may supply both a value for the Name and the Key for each level. This example loads the local cube from an Analysis Services cube. You can also write a Select statement that loads the local cube from a set of relational tables. INSERTINTO=INSERT INTO LocalCube
The Connection String You build the connection string as the combination of these four strings: sConnection = sLocation & ";" & sSourceDSN & ";" & sCreateCube & ";" & sInsertInto Sample VB Projects to Create Local Cubes We have prepared two sample Visual Basic projects that create local cubes - one for SQL Server 7.0 and one for SQL Server 2000. Here are the steps you have to follow to make the code work: 1. Download the project and module files and open the project in Visual Basic 6.0. 2. Modify the location string so that it points to a valid path. 3. Modify the DSN so it points to a name of a valid Analysis Server (OLAP Server) that has the FoodMart sample database installed. (The code could fail if you have modified FoodMart from its original form.) 4. Execute the project. The local cube should be created. 5. Experiment with modifying the cube. Make sure you make changes in the appropriate places in the Create Cube and Insert Into strings. If, for example, you want to remove one of the levels of a dimension, remove the references to that level from the Create Cube command, from the Insert Into clause of the Insert Into command, and from the Select clause of the Insert Into command. DOWNLOAD THE FILES FOR CREATE CUBE PROJECT FOR SQL SERVER 2000: modCreateCube2000.bas CreateLocalCube2000.vbp
|
|||||||||||||