Class ODBCConnection (Excel VBA)

The class ODBCConnection represents the ODBC connection.

Methods

Other Methods

SaveAsODC - Saves the ODBC connection as a Microsoft Office Data Connection file.

Sub UseSaveAsODC() 
 
 Application.ActiveWorkbook.ODBCConnection.SaveAsODC ("ODCFile") 
 
End Sub

Properties

AlwaysUseConnectionFile true if the connection file is always used to establish connection to the data source.

BackgroundQuery true if queries for the ODBC connection are performed asynchronously (in the background).

CommandText returns or sets the command string for the specified data source. Read/write Variant.

Set qtQtrResults = _ 
 Workbooks(1).Worksheets(1).QueryTables(1) 
With qtQtrResults 
 .CommandType = xlCmdSQL 
 .CommandText = _ 
 "Select ProductID From Products Where ProductID < 10" 
 .Refresh 
End With 

CommandType returns or sets one of the XlCmdType constants.

Set qtQtrResults = _ 
 Workbooks(1).Worksheets(1).QueryTables(1) 
With qtQtrResults 
 .CommandType = xlCmdSQL 
 .CommandText = _ 
 "Select ProductID From Products Where ProductID < 10" 
 .Refresh 
End With 

Connection returns or sets a string that contains ODBC settings that enable Microsoft Excel to connect to an ODBC data source.

EnableRefresh true if the connection can be refreshed by the user. The default value is True.

Parent returns the parent object for the specified object. Read-only.

RefreshDate returns the date on which the ODBC connection was last refreshed.

Refreshing true if a background ODBC query is in progress for the specified ODBC connection.

RefreshOnFileOpen true if the connection is automatically updated each time the workbook is opened. The default value is False.

RefreshPeriod returns or sets the number of minutes between refreshes.

RobustConnect returns or sets how an ODBC connection connects to its data source.

SavePassword true if password information in an ODBC connection string is saved in the connection string. False if the password is removed.

ServerCredentialsMethod returns or sets the type of credentials that should be used for server authentication.

ServerSSOApplicationID returns or sets a single sign-on application (SSO) identifier that is used to do a lookup in the SSO database for credentials.

SourceConnectionFile returns or sets a String indicating the Microsoft Office Data Connection file or similar file that was used to create the connection.

SourceData returns the data source for the ODBC connection, as shown in the table.

SourceDataFile returns or sets a String indicating the source data file for an ODBC connection.