04 Connect - AndrewMB2/Logic-Architect-for-Excel-VBA GitHub Wiki
Connect method
Connects to a database. Returns True if successful, otherwise False.
Applies to
| TableData | ArrData | RsetData | Xdata | XShared |
|---|---|---|---|---|
| ✓ |
Parameters
| Name | Type | Description |
|---|---|---|
| Filename | String | Name/path or url/IP address of the database to connect. |
| ConnType | CnType enumeration | Type of database to connect (see below). |
| IMEX | Integer (optional) | IMEX=1 tells the driver to always read "intermixed" data columns as text, though the connection is then read only. |
| InitialCatalog | String (optional) | For SQL Server this is the Initial Catalog parameter in the connection string; For MySQL this is the Database parameter in the connection string; not used for other databases. |
| UserID | String (optional) | For SQL Server this is the User ID parameter in the connection string; for MySQL this is the UID parameter in the connection string; not used for other databases. |
| Password | String (optional) | For SQL Server this is the Password parameter in the connection string; for MySQL this is the PWD parameter in the connection string; not used for other databases. |
| CursorLocation | adCursorLocation enumeration (optional) | Cursor location; For more information see this Microsoft webpage. |
Connect connects to one of the supported databases. The type of database is specified in the ConnType parameter and can be one of:
| Value | Database | Default cursor location |
|---|---|---|
| cnExcel12xml | Excel workbook in open XML format | Server |
| cnExcel12 | Excel workbook in binary format | Server |
| cnAccess | Microsoft Access | Server |
| cnSQLServer | Microsoft SQL Server | Client |
| cnMySql | MySQL | Client |
| cnDBISAM | DBISAM (Elevate Software) | Client |
If the method fails, the error number is stored in the RsetData object's ErrNumber property.