See Also
Applies To
Data control, Database object
Description
Determines the information used to open an external database
Data controlRead/write at design time and run time.
Database objectRead-only.
TableDef objectRead/write at run time only in the Professional Edition with a new object not yet appended to a collection.
Note When using a Microsoft Access database, leave this property blank.
Syntax
{ database | tabledef | datactrl }.Connect [ = connectinfo ]
Remarks
The database is the Database property of a data control. In the Professional Edition, it can also be an object variable identifying an open Database. The tabledef can be a member of the TableDefs collection of a data control's Database property. In the Professional Edition, a tabledef can also be an object variable identifying an existing TableDef.
You can use the DatabaseName, Exclusive, ReadOnly, and Connect properties to open a database with a data control. For example, a data control uses these property settings to open a Paradox database:
Data1.DatabaseName = "C:\PDX\PUBS"
Data1.Exclusive = True
Data1.ReadOnly = False
Data1.Connect = "Paradox;"
In the Professional Edition, these properties represent the arguments in the OpenDatabase function. For example, the following code opens the same Paradox database:
Set MyDB = OpenDatabase("C:\PDX\PUBS", True, False, "Paradox;")
For ODBC external databases such as SQL Server or Oracle (which must have been registered with ODBC.INI), the Connect property value for the database might be as follows:
ODBC;DSN=ourdbsrvr,UID=guest;PWD=guest;
DSN is the data source name, UID is the user ID, and PWD is the password.
For a TableDef of a non-ODBC attached table, the Connect property is the path name of the file containing the table and the SourceTableName property identifies the Table within that file. For ODBC attached tables, the Connect property is the same as for the ODBC database.
Note For an attached table, you must set both the Connect and SourceTableName properties before using the Append method in order to establish a link.
If you provide no values (or empty strings) for the DatabaseName and Connect properties, a list of registered ODBC data source names appears, allowing a user to select one.
For more information about ODBC drivers such as SQL Server or Oracle, see the Help file provided with the driver.
If a password is required but not provided in the Connect property, a Login dialog box appears each time a table is accessed.
In the Professional Edition, you can attach a table of an external database or of another Microsoft Access database by creating a new TableDef object, setting the SourceTableName and Connect properties, then appending the TableDef to the TableDefs collection of a Database.
Data Type
String
Help:
Attributes Property
DatabaseName Property
Exclusive Property
New
OpenDatabase Function (Professional Edition Only)
ReadOnly Property
TableDefs Collection
Data Access Guide:
Chapter 2, "Database Management Using Visual Basic"
Programmer's Guide:
Chapter 20, "Accessing Databases with the Data Control"