This documentation is archived and is not being maintained.

_QueryTable.Connection Property 

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

Namespace: Microsoft.Office.Interop.Excel
Assembly: Microsoft.Office.Interop.Excel (in

Dim _QueryTable1 As _QueryTable

Dim returnValue As Object
returnValue = _QueryTable1.Connection

Dim sampleValue As Object
_QueryTable1.Connection = sampleValue

object Connection {get; set;}
public System.Object get_Connection();
public void set_Connection(System.Object);
function get Connection() : Object;
function set Connection(Object);

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 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 method of the QueryTables collection and the Add method of the PivotCaches collection.

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

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

Development Platforms

Windows XP Home Edition, Windows XP Professional, Windows Server 2003, and Windows 2000

Target Platforms