clsServer
[!NOTA] Questa funzionalità verrà rimossa a partire dalla prossima versione di Microsoft SQL Server. Non utilizzare questa funzionalità in un nuovo progetto di sviluppo e modificare appena possibile le applicazioni in cui questa funzionalità viene utilizzata.
An object of ClassType clsServer provides methods and properties that enable you to control an Analysis server. This object is the root of the Decision Support Objects (DSO) object model tree that specifies the databases, cubes, and user roles managed by the server. With an object of ClassType clsServer you can:
- Connect to a computer where the Analysis server service (MSSQLServerOLAPService) is running.
- Start and stop the server.
- Create and manage objects that define multidimensional data structures.
An object of ClassType clsServer provides collections, methods, and properties through its own internal interface.
Examples
A. Creating and Initializing a Server
Use the following code to create and initialize a server. You can use LocalHost to specify the Analysis server running on the same computer as your DSO application.
'Create instance of server and connect
Public dsoServer As DSO.Server
Set dsoServer = New DSO.Server
'ServerName is the Windows NT 4.0 Server or Windows 2000 Server computer
'where the Analysis service is loaded and running.
'An error is raised if the connection attempt fails
dsoServer.Connect "ServerName"
This example accomplishes the same result:
DsoServer = New DSO.Server
dsoServer.Name = "ServerName"
dsoServer.Connect
B. Creating and Connecting to a Server
The following example shows how to create an instance of a DSO object of ClassType clsServer and connect to an Analysis server:
Public Sub ConnectToServer()
Dim dsoServer As DSO.Server
On Error GoTo ErrHandler
' Initialize server.
Set dsoServer = New DSO.Server
' Connect to the local Analysis server.
' If a connection cannot be made, an error is raised.
dsoServer.Connect "LocalHost"
' Print server properties to the Debug window.
With dsoServer
Debug.Print "Server Properties --------------------------"
Debug.Print "Name: " & .Name
Debug.Print "Description: " & .Description
Debug.Print "ConnectTimeout: " & .ConnectTimeout
Debug.Print "LockTimeout: " & .LockTimeout
Debug.Print "Version: " & .Version
End With
' Close connection to server.
dsoServer.CloseServer
ExitRoutine:
Set dsoServer = Nothing
Exit Sub
ErrHandler:
Debug.Print "Error connecting to server:"
Debug.Print Err.Number, Err.Description, Err.Source
End Sub
Vedere anche
Riferimento
Collections, clsServer
Methods, clsServer
Properties, clsServer