ActiveConnection Property (ADO MD)

   Example   Applies To   

The ActiveConnection property indicates to which Connection object the current Cellset or Catalog currently belongs.

Settings and Return Values

ActiveConnection sets or returns a Variant that contains a String defining a connection or Connection object. Default is empty. ActiveConnection is read/write.

Remarks

You can set this property to a valid ADO Connection object or to a valid connection string. When this property is set to a connection string, the provider creates a new Connection object using this definition and opens the connection.

If you use the ActiveConnection argument of the Open method to open a Cellset object, the ActiveConnection property will inherit the value of the argument.

Setting the ActiveConnection property of a Catalog object to Nothing releases the associated data, including data in the CubeDefs collection and any related Dimension, Hierarchy, Level, and Member objects. Closing a Connection object that was used to open a Catalog has the same effect as setting the ActiveConnection property to Nothing.

An error will occur if you attempt to change the ActiveConnection property for an open Cellset object.

Note   Remember to use the Set keyword when setting the ActiveConnection property to a Connection object. If you omit the Set keyword you will actually be setting the ActiveConnection property equal to the Connection object's default property: ConnectionString. The code will work; however, you will create an additional connection to the data source, which may have negative performance implications.

To specify a connection string to an OLAP server, the Data Source property should be set to a Data Source name supported by the server. To connect to a cube file that is disconnected from a server, set the Location property to the full path to the .CUB file. In either case, the Provider property should be set to a provider name. For example, the following string connects to a Data Source named Bobs Video Store with a Provider named msolap:

"Data Source=Bobs Video Store;Provider=msolap"

The following string connects to a local cube file at the location C:\MSDASDK\samples\oledb\olap\data\bobsvid.cub:

"Location=C:\MSDASDK\samples\oledb\olap\data\bobsvid.cub;Provider=msolap"