Connect Property

       

Sets or returns a value that provides information about the source of an open connection, an open database, a database used in a pass-through query, or a linked table. For Database objects, new Connection objects, linked tables, and TableDef objects not yet appended to a collection, this property setting is read/write. For QueryDef objects and base tables, this property is read-only.

Syntax

object.Connect = databasetype;parameters;

The Connect property syntax has these parts.

Part

Description

object

An object expression that evaluates to an object in the Applies To list.

databasetype

Optional. A String that specifies a database type. For Microsoft Jet databases, exclude this argument; if you specify parameters, use a semicolon (;) as a placeholder.

parameters

Optional. A String that specifies additional parameters to pass to ODBC or installable ISAM drivers. Use semicolons to separate parameters.

 

Settings

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 Jet database (.mdb) file, you must first set the Connect property of the linked table's database to a valid ODBC connection string.

For a TableDef object that represents a linked table, the Connect property setting consists of one or two parts (a database type specifier and a path to the database), each of which ends with a semicolon.

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 Jet 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. In an ODBCDirect workspace, only the "ODBC" specifier can be used.

Database type

Specifier

Example

Microsoft Jet Database

[database];

drive:\path\filename.mdb

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 FoxPro 2.0

FoxPro 2.0;

drive:\path

Microsoft FoxPro 2.5

FoxPro 2.5;

drive:\path

Microsoft FoxPro 2.6

FoxPro 2.6;

drive:\path

Microsoft Visual FoxPro 3.0

FoxPro 3.0;

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.mdb

 

Remarks

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.

For base tables in a Micorosoft Jet database (.mdb), the Connect property setting is a zero-length string ("").

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.

On a QueryDef object in a Microsoft Jet workspace, you can use the Connect property with the ReturnsRecords property to create an ODBC SQL pass-through query. The databasetype of the connection string is "ODBC;", and the remainder of the string contains information specific to the ODBC driver used to access the remote data. For more information, see the documentation for the specific driver.

Notes

?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.