To access data using your Data Environment, you must create a Connection object. Therefore, every Data Environment should include at least one Connection object. A Connection object represents a connection to a remote database that is used as a data source.
Upon adding a Data Environment to your Visual Basic project, the Data Environment designer automatically includes a new connection, called Connection1. At design time, the Data Environment opens the connection and obtains metadata from the connection, including database object names, table structures, and procedure parameters.
Note If Show properties immediately after object creation is selected in the Options dialog box, the Data Link Properties dialog box will appear when you add a Data Environment to your project. This option is not selected by default.
The Add Connection function is available at all times and is independent of the existence of other objects.
To create a database connection
-or–
Right-click your Data Environment designer and select Add Connection from the shortcut menu.
Once you have added a Connection, the Data Environment is updated to show the new Connection object. The default name for this object is "Connection," followed by a number, such as Connection1.
Use the following procedure to specify Connection object properties.
To set the Connection Name and Data Source
Note Regardless of the selected data source type, the Data Environment accesses all data via ADO and OLE DB interfaces.
Logon information only needs to be supplied if the database being accessed via the Connection object requires authentication information. You can specify a different set of logon information to be used at design time and run time. For example, you might want to develop your application using a system administrator user identification and password, but supply a general guest user identification when the application is run.
Note Any logon information specified on the Data Link Properties dialog box is overridden by logon information specified on the Visual Basic Properties window.
To specify logon information
Note Since the password is not encrypted, for maximum security you should not specify your password to persist for run time or design time.
The miscellaneous connection information consists of advanced options that change how the database is accessed.
To specify miscellaneous information
Note A Connection object is not opened until information is needed from the connection, such as a list of tables. When a Connection object is selected in the Data Environment outline view, the status bar text can be used to determine if the connection is currently established (open).
You can automatically create Connection objects by dragging a connection from the Data View window to your Data Environment designer. This is an easy and efficient way to create Connection objects that already exist in your Data View.