MDAC 2.5 SDK - OLE DB Programmer's Reference
Chapter 20: OLE DB Core Components
The Data Link API exposes a user interface that you can implement in your applications to create and manage connections to OLE DB data stores.
Because the Data Link API is included with OLE DB as a core component, the user interface is always available to your application users if ADO or OLE DB is properly installed on their system.
Before you can access data from OLE DB, you must provide specific connection information such as the following:
For example, to connect to a Microsoft® SQL Server™ database, you must specify the OLE DB provider for SQL Server, a server name, and a database name.
You can call the Data Link API to build a string version of this connection information, which you can save and reuse in your applications. This string version is referred to as a connection string. The user interface object that prompts users to build the connection string is referred to as the Data Link Properties dialog box. The information specified in a connection string may vary depending on the OLE DB provider that is specified.
Using the Data Link Properties dialog box, your end users can build connection strings directly within your application. Once created, a connection string can be saved by using either of the following methods:
These two methods of saving a connection string are compared in the following table.
Saving a connection string with the application data | Saving a connection string as a data link (.udl) file |
Connection string is saved and stored with the application. | Connection string is saved as a .udl file, enabling users to save and modify it from their system. |
Connection string is part of the application and is therefore automatically redistributed with the application. | The .udl file must be included as a separate file when you redistribute your application. |
If the connection information changes, the connection string must be modified from within your application. | Users can modify the .udl file at any time if the connection information changes. |
Users can also build connection strings using the Data Link Properties dialog box. On Microsoft Windows® 95 systems, a Data Link icon was created in the Windows Control Panel when Data Access components were installed. On Windows 98 and Windows NT systems where Data Access components were installed, right-clicking on the Desktop allowed the user to select New and then Microsoft Data Link to create a .udl file.
On computers running the Windows 2000 operating system, you can access the Data Link Properties dialog box by following these steps:
Users can store .udl files anywhere on their system or network.
Note You can manually build a connection string as long as it conforms to the syntax rules. For more information about the format of a connection string, see Connection String Syntax.
The Data Link API includes the following dialog boxes:
Note To get help information about the Data Link interface, press F1 while viewing an active dialog box.
The Data Link Properties dialog box is typically used either to edit an existing connection string or to build a new connection string. This tabbed dialog box exposes all of the properties that the selected OLE DB provider supports. For example, the Advanced tab includes default settings that the user can modify as necessary. The Connection tab is provider-specific.
If, instead of storing a connection string directly within your application, you want your application to reference a .udl file, you can prompt users with the Select Data Link File dialog box. This allows the user to select from existing .udl files as well as to create new ones.
For example, if your application supports .udl files, a user could create a .udl file that points to the user's Customer database. Then, by using the Select Data Link File dialog box, the user could specify this .udl file to access the Customer database.
Referencing a .udl file is beneficial to users if a database is upgraded to a different server or is modified. In either case, the user simply edits the connection string within the .udl file with the updated information, and the application that uses this file will instantly reflect the changes.
The Select Data Link File dialog box returns the selected .udl file to the application.
The properties in the following list will not be persisted to the .udl file. They are generally set by the connecting application at run time. Although these can be set manually, they could be easily overwritten by the connecting application.
See Also