The data link API exposes a user interface that you can implement in your applications to create and manage connections to OLE DB data sources.
Because the data link API is included with OLE DB as a core component, you can always assume that the user interface is available to your application users if ADO or OLE DB is properly installed on their system.
This section includes the following topics:
Using the Data Link API
Before you can access data from OLE DB, you must provide specific connection information such as:
For example, to connect to a Microsoft® SQL Server™ database you need to 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 that you can save and reuse in your applications. This string version is referred to as a connection string. The user interface that prompts users to build the connection string is referred to as the data link dialog boxes. The information specified in a connection string may vary depending on the OLE DB provider that is specified.
Building and Saving Connection Strings Using the Data Link Properties Dialog Box
Using the data link dialog boxes, your end users can build connection strings directly within your application. Once created, a connection string can be saved with the application itself or as a separate file with the .udl extension. This file is referred to as a Microsoft Data Link file.
Each method of saving a connection string is compared below.
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 an .udl file, enabling users to save and modify it from their system. |
Connection string is part of the application and is thus 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 anytime if the connection information changes. |
As a programmer, you can use either method to prompt users to build connection strings while using your application. You call the same data link dialog boxes regardless of the method used.
Users can also build connection strings from Control Panel by clicking the Data Links icon. The Data Links icon opens the Organize Data Link Files dialog box, which allows users to create new .udl files or modify the connection string in existing .udl files. 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.
Data Link API User Interface Components
The data link API includes the following dialog boxes:
Note To get help about the data link interface, press F1 while viewing an active dialog box.
Users typically use the Data Link Properties dialog box either to edit an existing connection string, or to build a new connection string. This is a tabbed dialog box that 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.
Depending on which OLE DB provider the user selects, the tabs and the options in this dialog box may vary.
To create or edit data link (.udl) files, which contain connection strings that have been saved, users use the Organize Data Link Files dialog box. Users can also access this dialog box from Control Panel by clicking the Data Links icon.
If you want your application to reference a .udl file instead of storing a connection string directly in your application, 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 an .udl file that points to the user's Customer database. Using the Select Data Link dialog box, the user could then specify this .udl file to access the Customer database.
Referencing an .udl file is beneficial to users if a database is upgraded to a different server or is modified. In this 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 is the same as the Organize Data Links dialog box, but it returns the selected .udl file to the application.
See Also