The example code in this section shows you how to connect to an OLAP server and list some of its property values. You must complete this section before moving on to subsequent examples.
Begin a new Microsoft® Visual Basic® project. Be sure to add Microsoft Decision Support Objects and Microsoft ActiveX® Data Objects to the program references.
Add the following to the Declarations section of the form:
Option Explicit
Public dsoServer As DSO.Server
Public dsoDB As DSO.MDStore
Public dsoCube As DSO.MDStore
In the Form_Load section add the following code:
Private Sub Form_Load()
On Error GoTo FormLoad_Err
Dim intClassType As Integer
Dim strClassType As String
'Initialize global objects
Set dsoDB = Nothing
Set dsoCube = Nothing
'Create instance of server and connect.
'"LocalHost" will default to the
'local Windows NT Server where the
'OLAP server is installed.
Set dsoServer = New DSO.Server
dsoServer.Connect ("LocalHost")
'Get the class type and describe it.
intClassType = dsoServer.ClassType
Select Case intClassType
Case clsServer
strClassType = "Server"
Case Else
strClassType = "Invalid Class Type"
End Select
'Show the server’s information to the user.
Debug.Print "Server Properties:"
Debug.Print "Name: " & dsoServer.Name
Debug.Print "ClassType: " & dsoServer.ClassType
Debug.Print "Description: " & dsoServer.Description
Debug.Print "machine: " & dsoServer.Machine
Exit Sub
FormLoad_Err:
Debug.Print "Error connecting to server"
Debug.Print Err.Number, Err.Description, Err.Source
Err.Clear
Debug.Assert False
End Sub
If the OLAP server is not installed on the computer on which you are running this example, change “LocalHost” to the name of the Microsoft Windows NT® Server computer where the OLAP server is installed and running.
Save your project and run the application. Check the output in the Immediate window to confirm that your server has been successfully initialized.