To connect with a cube, you should use the C1OlapPanel.ConnectCube method. This method accepts two parameters: the connection string to a SQL Server with Analysis Services installed, and the name of the cube. You can report errors to the user by catching an Exception at run-time. Here is a complete coded example of connecting to a cube.
Visual Basic |
Copy Code
|
---|---|
' connect to cube stringconnectionString = "Data Source=myServerAddress;Catalog=myDataBase" stringcubeName = "Adventure Works" Try _c1OlapPage.OlapPanel.ConnectCube(cubeName, connectionString) Catch generatedExceptionName As Exceptionex MessageBox.Show(ex.Message) End Try |
C# |
Copy Code
|
---|---|
// connect to cube stringconnectionString = @"Data Source=myServerAddress;Catalog=myDataBase"; stringcubeName = "Adventure Works"; try { _c1OlapPage.OlapPanel.ConnectCube(cubeName, connectionString); } catch(Exceptionex) { MessageBox.Show(ex.Message); } |
The connection string should set the Data Source and the Initial Catalog. If you have more than one Microsoft OLE DB provider for OLAP installed, you may need to specify the version of the provider in the connection string. For example, setting the Provider to MSOLAP will use the latest version of OLE DB for OLAP installed on your system.
Example:
Visual Basic |
Copy Code
|
---|---|
Provider = MSOLAP Dim Source As Data = myServerAddress Dim Catalog As Initial = myDataBase |
C# |
Copy Code
|
---|---|
Provider=MSOLAP;Data Source=myServerAddress;Initial Catalog=myDataBase; |