Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
MSDN Library

AdomdConnection Class

 

Represents a connection to a multidimensional data source.

Namespace:   Microsoft.AnalysisServices.AdomdClient
Assembly:  Microsoft.AnalysisServices.AdomdClient (in Microsoft.AnalysisServices.AdomdClient.dll)

System.Object
  System.MarshalByRefObject
    System.ComponentModel.Component
      Microsoft.AnalysisServices.AdomdClient.AdomdConnection

public sealed class AdomdConnection : Component, IDbConnection, 
	IDisposable, ICloneable

NameDescription
System_CAPS_pubmethodAdomdConnection()

Initializes a new instance of the AdomdConnection class with default values.

System_CAPS_pubmethodAdomdConnection(AdomdConnection)

Initializes a new instance of the AdomdConnection class by using values from a specified AdomdConnection class. The session identifier and command state are not the same.

System_CAPS_pubmethodAdomdConnection(String)

Initializes a new instance of the AdomdConnection class by using the specified connection string.

NameDescription
System_CAPS_pubpropertyClientVersion

Gets the version of the ADOMD.NET client that implements the AdomdConnection.

System_CAPS_pubpropertyConnectionString

Gets or sets the string that the AdomdConnection uses to open an analytical data source.

System_CAPS_pubpropertyConnectionTimeout

Gets the time to wait for a connection to be established before the AdomdConnection stops trying to connect and generates an error.

System_CAPS_pubpropertyContainer

(Inherited from Component.)

System_CAPS_pubpropertyCubes

Gets an instance of a CubeCollection that represents the collection of cubes contained by an analytical data source.

System_CAPS_pubpropertyDatabase

Gets the name of the database to be used after the AdomdConnection is open.

System_CAPS_pubpropertyMiningModels

Gets an instance of a MiningModelCollection that represents the collection of mining models that an analytical data source contains.

System_CAPS_pubpropertyMiningServices

Gets an instance of a MiningServiceCollection that represents the collection of mining services that an analytical data source contains.

System_CAPS_pubpropertyMiningStructures

Gets an instance of a MiningStructureCollection that represents the collection of mining structures that an analytical data source contains.

System_CAPS_pubpropertyProviderVersion

Gets the version of the XML for Analysis provider that the AdomdConnection uses.

System_CAPS_pubpropertyServerVersion

Gets the version of the server used that the AdomdConnection uses.

System_CAPS_pubpropertySessionID

Gets or sets the string identifier of the session that the AdomdConnection opened with the server.

System_CAPS_pubpropertyShowHiddenObjects

Gets or sets a value that indicates whether hidden objects are returned.

System_CAPS_pubpropertySite

(Inherited from Component.)

System_CAPS_pubpropertyState

Gets the current state of the AdomdConnection.

NameDescription
System_CAPS_pubmethodBeginTransaction()

Begins a new transaction.

System_CAPS_pubmethodBeginTransaction(IsolationLevel)

Begins a new transaction with the specified IsolationLevel enumeration value.

System_CAPS_pubmethodChangeDatabase(String)

Changes the current database of the open AdomdConnection.

System_CAPS_pubmethodClone()

Creates and returns an instance of an AdomdConnection based on the current AdomdConnection. Session ID and state are not cloned.

System_CAPS_pubmethodClose()

Closes the connection to the database and ends the session.

System_CAPS_pubmethodClose(Boolean)

Closes the connection to the database, indicating whether to end the session.

System_CAPS_pubmethodCreateCommand()

Creates and returns an AdomdCommand that is associated with the AdomdConnection.

System_CAPS_pubmethodCreateObjRef(Type)

(Inherited from MarshalByRefObject.)

System_CAPS_pubmethodDispose()

(Inherited from Component.)

System_CAPS_pubmethodEquals(Object)

(Inherited from Object.)

System_CAPS_pubmethodGetHashCode()

(Inherited from Object.)

System_CAPS_pubmethodGetLifetimeService()

(Inherited from MarshalByRefObject.)

System_CAPS_pubmethodGetSchemaDataSet(Guid, Object[])

Returns schema information from a data source by using a Guid object to specify which schema information to return and by applying any specified restrictions to the information.

System_CAPS_pubmethodGetSchemaDataSet(Guid, Object[], Boolean)

Returns schema information from a data source by using a Guid object to identify the information, applying any specified restrictions on the information, and optionally throwing an exception when inline errors occur.

System_CAPS_pubmethodGetSchemaDataSet(String, AdomdRestrictionCollection)

Returns schema information from a data source by using a schema name to identify which schema to retrieve and by applying any specified restrictions to the information.

System_CAPS_pubmethodGetSchemaDataSet(String, AdomdRestrictionCollection, Boolean)

Returns schema information from a data source by using a schema name to identify the information, applying any specified restrictions to the information, and optionally throwing an exception when inline errors occur.

System_CAPS_pubmethodGetSchemaDataSet(String, String, AdomdRestrictionCollection)

Returns schema information from a data source by using a schema name and namespace to identify the information, and by applying any specified restrictions to the information.

System_CAPS_pubmethodGetSchemaDataSet(String, String, AdomdRestrictionCollection, Boolean)

Returns schema information from a data source by using a schema name and namespace to identify the information, applying any specified restrictions to the information, and, optionally throwing an exception when inline errors occur.

System_CAPS_pubmethodGetType()

(Inherited from Object.)

System_CAPS_pubmethodInitializeLifetimeService()

(Inherited from MarshalByRefObject.)

System_CAPS_pubmethodOpen()

Opens a connection with an analytical data source by using the settings specified in the ConnectionString property of the AdomdConnection.

System_CAPS_pubmethodOpen(String)

This API supports the product infrastructure and is not intended to be used directly from your code. Opens a connection with an analytical data source by using the specified path..

System_CAPS_pubmethodRefreshMetadata()

Forces the connection to repopulate all metadata from the server.

System_CAPS_pubmethodToString()

(Inherited from Component.)

NameDescription
System_CAPS_pubeventDisposed

(Inherited from Component.)

NameDescription
System_CAPS_pubinterfaceSystem_CAPS_privmethodIDbConnection.BeginTransaction()

Begins a database transaction.

System_CAPS_pubinterfaceSystem_CAPS_privmethodIDbConnection.BeginTransaction(IsolationLevel)

Begins a database transaction with the specified isolation level value.

System_CAPS_pubinterfaceSystem_CAPS_privmethodIDbConnection.CreateCommand()

Creates a new AdomdCommand associated with this connection and returns its IDbCommand object.

System_CAPS_pubinterfaceSystem_CAPS_privmethodICloneable.Clone()

Creates and returns an instance of an AdomdConnection based on the current AdomdConnection. Session ID and state are not cloned.

The AdomdConnection represents a connection with an analytical data source (for example, a connection to an instance of Microsoft SQL Server 2005 Analysis Services (SSAS)). Each connection is associated with an XML for Analysis session. If an AdomdConnection goes out of scope, the connection is not closed. To close the connection, you must explicitly call the Close or Dispose method of the AdomdConnection. If the Close or Dispose method is not called, the session associated with the AdomdConnection remains active and can be reused by another AdomdConnection. For more information about managing sessions, see Working with Connections and Sessions in ADOMD.NET and SessionID.

Legacy Code Example

The following subroutine uses the given arguments to build a connection string that the subroutine uses to try to connect to a specified instance of Analysis Services and return an AdomdConnection:

Public Function Connect(Optional ByVal ServerID As String = "localhost", _
    Optional ByVal DatabaseID As String = "", _
    Optional ByVal UserID As String = "", _
    Optional ByVal Password As String = "") As AdomdConnection

    Dim strConnectionString As String
    Dim objConnection As AdomdConnection

    Try
        ' First, build the connection string.
        ' 
        ' The ConnectionString property consists of 
        
        ' key/value pairs seperated by semicolons.
        ' - The format, as a regular expression, should be:
        ' (<Key>=<Value>)*([[;]/*(<Key>=<Value>)])

        ' The connection string can take "Datasource", "Data Source", 
        ' or "Location" for this parameter.
        If ServerID <> "" Then
            strConnectionString &= "Data Source=" & ServerID & ";"
        End If

        ' The connection string can take "Catalog" or "Initial Catalog" 
        ' for this parameter.
        If DatabaseID <> "" Then
            strConnectionString &= "Initial Catalog=" & DatabaseID & ";"
        End If

        ' The connection string can take "UID", "User ID", 
        ' "Authenticated User", or "UserName" for this parameter.
        If UserID <> "" Then
            strConnectionString &= "User ID=" & UserID & ";"
        End If

        ' The connection string can take "PWD" or "Password" 
        ' for this parameter.
        If Password <> "" Then
            strConnectionString &= "Password=" & Password & ";"
        End If

        ' Get a reference to an AdomdConnection object.
        objConnection = New AdomdConnection()

        ' Assign the connection string and try to 
        ' open a connection.
        objConnection.ConnectionString = strConnectionString
        objConnection.Open()

        Catch ex As AdomdConnectionException
            ' The connection could not be opened or was disconnected.
            ' This error can occur at any time, if the provider is 
            ' disconnected from the server.
            Debug.WriteLine(ex)
        Catch ex As AdomdErrorResponseException
            ' A response is received from a provider that indicates an error.
            Debug.WriteLine(ex)
        Catch ex As AdomdUnknownResponseException
            ' A response has been returned from the provider that 
            ' was not understood.
            Debug.WriteLine(ex)
        Catch ex As AdomdCacheExpiredException
            ' A cached version of an ADOMD.NET object is no longer valid.
            ' This error is typically raised when reviewing metadata.
            Debug.WriteLine(ex)
        Catch ex As AdomdException
            ' Any other error raised by ADOMD.NET.
            Debug.WriteLine(ex)
        Catch ex As Exception
            ' Any other error that occurs.
            Debug.WriteLine(ex)
    Finally
        Debug.Write("The connection ")
        If objConnection.State = ConnectionState.Open Then
            Debug.WriteLine("is connected!")
        Else
            Debug.WriteLine("failed to connect!")
        End If
    End Try
    
    ' Return the AdomdConnection object.
    Return objConnection
End Function

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top

Community Additions

Show:
© 2015 Microsoft