_QueryTable.Connection _QueryTable.Connection _QueryTable.Connection Property


Returns or sets a string that contains connection information for the query table. Read/write Object.

 property System::Object ^ Connection { System::Object ^ get(); void set(System::Object ^ value); };
public object Connection { get; set; }
Public Property Connection As Object

Property Value


The Connection property can be one of the following: OLE DB settings that enable Microsoft Excel to connect to an OLE DB data source, ODBC settings that enable Microsoft Excel to connect to an ODBC data source, a URL that enables Microsoft Excel to connect to a Web data source, the path to and file name of a text file, or the path to and file name of a file that specifies a database or Web query.

Setting the Connection property doesn’t immediately initiate the connection to the data source. You must use the Refresh(Object) method to make the connection and retrieve the data.

When using an offline cube file, set the UseLocalConnection property to True and use the LocalConnection property instead of the Connection property.

For more information about the connection string syntax, see the Add(Object, Range, Object) method of the QueryTables collection and the Add(XlPivotTableSourceType, Object) method of the PivotCaches collection.

Alternatively, you may choose to access a data source directly by using the Microsoft ActiveX Data Objects (ADO).

Applies to