Connect Property

See Also    Example    Applies To

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 CdbDatabase objects, new CdbConnection objects, linked tables, and CdbTableDef objects not yet appended to a collection, this property setting is read/write. For CdbQueryDef objects and base tables, this property is read-only.

Syntax

VOIDSetConnect(LPCTSTR pstrConnect);

CStringGetConnect(VOID);

Parameters

Type Argument Description
LPCTSTR pstrConnect A pointer to a string that specifies additional parameters to pass to ODBC or installable ISAM drivers. Use semicolons to separate parameters.

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 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 CdbTableDef 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. You can also specify “FTP://path/etc.” or “HTTP://path/etc.” For the path. 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
FoxPro 2.0 FoxPro 2.0; drive:\path
FoxPro 2.5 FoxPro 2.5; drive:\path
FoxPro 2.6 FoxPro 2.6; drive:\path
Excel 3.0 Excel 3.0; drive:\path\filename.xls
Excel 4.0 Excel 4.0; drive:\path\filename.xls
Excel 5.0 or Excel 95 Excel 5.0; drive:\path\filename.xls
Excel 97 Excel 97; drive:\path\filename.xls
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
Exchange Exchange;
MAPILEVEL=folderpath; [TABLETYPE={ 01 }];[PROFILE=profile;]
[PWD=password;]
[DATABASE=database;]
drive:\path\filename.mdb

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 Microsoft Jet database (.mdb), the Connect property setting is a zero-length string ("").

You can set the Connect property for a CdbDatabase 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 CdbQueryDef 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