Database.Connect property (DAO)

Applies to: Access 2013, Office 2013

Sets or returns a value that provides information about the source an open database. Read/write String.

Syntax

expression .Connect

expression A variable that represents a Database object.

Remarks

The Connect property setting is a String composed of a database type specifier and zero or more parameters separated by semicolons. The Connect property passes additional information to ODBC and certain ISAM drivers as needed.

To perform an SQL pass-through query on a table linked to your Microsoft Access database file, you must first set the Connect property of the linked table's database to a valid ODBC connection string.

The path as shown in the following table is the full path for the directory containing the database files and must be preceded by the identifier DATABASE=. In some cases (as with Microsoft Excel and Microsoft Access database engine databases), you should include a specific file name in the database path argument.

The following table shows possible database types and their corresponding database specifiers and paths for the Connect property setting.

Database type

Specifier

Example

Microsoft Access Database

[database];

drive:\path\filename

dBASE III

dBASE III;

drive:\path

dBASE IV

dBASE IV;

drive:\path

dBASE 5

dBASE 5.0;

drive:\path

Paradox 3.x

Paradox 3.x;

drive:\path

Paradox 4.x

Paradox 4.x;

drive:\path

Paradox 5.x

Paradox 5.x;

drive:\path

Microsoft Excel 3.0

Excel 3.0;

drive:\path\filename.xls

Microsoft Excel 4.0

Excel 4.0;

drive:\path\filename.xls

Microsoft Excel 5.0 or Microsoft Excel 95

Excel 5.0;

drive:\path\filename.xls

Microsoft Excel 97

Excel 8.0;

drive:\path\filename.xls

Lotus 1-2-3 WKS and WK1

Lotus WK1;

drive:\path\filename.wk1

Lotus 1-2-3 WK3

Lotus WK3;

drive:\path\filename.wk3

Lotus 1-2-3 WK4

Lotus WK4;

drive:\path\filename.wk4

HTML Import

HTML Import;

drive:\path\filename

HTML Export

HTML Export;

drive:\path

Text

Text;

drive:\path

ODBC

ODBC; DATABASE=database; UID=user; PWD=password; DSN= datasourcename; [LOGINTIMEOUT=seconds;]

None

Microsoft Exchange

Exchange 4.0; MAPILEVEL=folderpath; [TABLETYPE={ 0 | 1 }];[PROFILE=profile;] [PWD=password;] [DATABASE=database;]

drive:\path\filename

If the specifier is only "ODBC;", the ODBC driver displays a dialog box listing all registered ODBC data source names so that the user can select a database.

If a password is required but not provided in the Connect property setting, a login dialog box is displayed the first time a table is accessed by the ODBC driver and again if the connection is closed and reopened.

For data in Microsoft Exchange, the required MAPILEVEL key should be set to a fully-resolved folder path (for example, "Mailbox - Pat SmithIAlpha/Today"). The path does not include the name of the folder that will be opened as a table; that folder’s name should instead be specified as the name argument to the CreateTable method. The TABLETYPE key should be set to "0" to open a folder (default) or "1" to open an address book. The PROFILE key defaults to the profile currently in use.

You can set the Connect property for a Database object by providing a source argument to the OpenDatabase method. You can check the setting to determine the type, path, user ID, password, or ODBC data source of the database.

Note

  • You must set the Connect property before you set the ReturnsRecords property.
  • You must have access permissions to the computer that contains the database server you're trying to access.