

object.Ĭonsole.WriteLine("Connection established successfully.") Ĭonsole.ForegroundColor = ConsoleColor.Yellow Ĭonsole.WriteLine("Server name:\t\t", server.Version) Ĭonsole.WriteLine("Press Enter to close this console window.") The using syntax ensures the correct use of the String ConnectionString = "DataSource=localhost" Connect to the local default instance of Analysis Services This example shows only some of the properties of a Server object, but there are more properties available, including ServerMode and DefaultCompatibilityLevel.
Tabular database example how to#
Code example: server connectionīelow is a C# code sample that shows how to connect to a local on-premises Analysis Services instance and list its properties in a console window. Although major and minor objects aren't used in a tabular model tree, the MajorObject class is visible as a base class for Server and Database objects, regardless of which API you use to set up the connection. Server and database connections are based on legacy AMO classes that inherit from MajorObject. See Install, reference and distribute the TOM client library for details. For this reason, the first step in setting up your project requires adding references to all of the AMO assemblies. Although TOM cannot be used to explore multidimensional metadata (Cubes), AMO can be used to explore both multidimensional and tabular metadata. In contrast, TOM does not have dependency on AMO. In order to make calls below the Database level (for example, on a model within a Tabular 1200 database, or on a Cube, Dimension, or MeasureGroup within a Multidimensional or Tabular 1050-1103 database), AMO has a dependency on TOM. This flexibility explains the dependencies among the assemblies.

Supporting a server and database connection through either namespace allows you to write generic tools or script that connect to any server instance or database, without having to know what type of model is hosted on the server. By separating the data definition language (DDL) into two separate namespaces, the development experience is simplified through the presentation of only the API needed for a specific model type.Īlthough the DDL differs, connections to a server are the same across all modes, versions, and editions. The metadata used for model definition and operations is completely different for the two modes. To make calls in the model tree, the Server or Database object is provided for both model types. Why two namespaces for the same operations? The answer lies downstream, at the database and model level, where the object hierarchy becomes mode-specific and the model tree is composed of either multidimensional or tabular metadata. Īs you can see, two namespaces provide connectivity to server and database objects: the original Microsoft.AnalysisServices namespace for AMO, and the new namespace for TOM.The following classes can be used for top-level connections: Once connected, properties of the Server object will reflect the settings of the current server instance. To connect to a server, your code must instantiate a Server object and then call the Connect method on it. This article explains how to establish a server connection using the namespace for models and databases created at 1200 or higher compatibility level. SQL Server 2016 and later Analysis ServicesĪnalysis Services Management Objects (AMO) includes several namespaces that can be used to set up a server connection.
