04 CreateConnection - AndrewMB2/Logic-Architect-for-Excel-VBA GitHub Wiki
CreateConnection method
Create a workbook connection from a previously created connection string. Returns True if successful, otherwise False.
Applies to
| TableData | ArrData | RsetData | Xdata | XShared |
|---|---|---|---|---|
| ✓ |
Parameters
| Name | Type | Description |
|---|---|---|
| ConnectionName | String | Name of the Workbook OLEDB connection to be created. |
| Description | String (optional) | Description to be stored in the connection. |
| iCmdType | Integer | Set to 2 for SQL, 3 for Table, 1 for OLAP cube. 2 (SQL) is the default, and should be used if the connection will be used in a RsetData object. |
| CommandText | String (optional) | SQL command text. |
CreateConnection creates a workbook connection from a previously created connection string for one of the databases supported by the Connect method (or replaces any existing workbook connection with this name). If Connect has already been run, then it is sufficient to run CreateConnection. If Connect has not been run, then it is possible to use GetConnectionString to get the connection string before running CreateConnection.
The default cursor location for the type of database is placed in brackets at the end of the description (see Connect), from which it is retrieved by the ConnectFrom method.