Delphi-Kylix
  Home arrow Delphi-Kylix arrow Creating Data Link (UDL) Files in Delphi
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Dedicated Servers  
Download TestComplete 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
eWeek
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
DELPHI-KYLIX

Creating Data Link (UDL) Files in Delphi
By: Danish Ahmed
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 3
    2007-08-06

    Table of Contents:
  • Creating Data Link (UDL) Files in Delphi
  • Section 1: Adding a new ODBC Data Source
  • Section 2: Connecting with SQL Server Drivers
  • Section 3: Creating Data Link files programmatically
  • Section 4: More undocumented routines in ADODB

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    Iron Speed
     
    ADVERTISEMENT

    Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!

    Creating Data Link (UDL) Files in Delphi
    (Page 1 of 5 )

    The connection string required to connect to a database server may be created during design time or run time. There are circumstances under which you may want to store the connection string entirely outside the application, however. In those instances, Microsoft Data Link files are useful, as this article will explain.

    In my last few articles I have been using ADOConnection component to connect to the database server. I have also explained the role of ConnectionString in an ADOConnection and demonstrated how to create one. The ConnectionString created during design time (like the one we created in my last article) is stored in the Form file (.dfm). Alternatively, we may decide to create it during runtime by hard coding the connection parameters.

    In both instances the ConnectionString can only be modified if the source is available. This may at times be undesirable, especially if the connection string needs to be modified, for example, when distributing the binary. In circumstances where hard-coding the connection parameters are not desirable, you can always fall back on Microsoft Data Link (.UDL) files or .INI files to store connection parameters outside the application. In this article I will discuss the methods to create UDL files to store and later retrieve the information required by ADO to connect to a database server.

    From information available on the Internet, one is inclined to think that Borland encourages developers to use ADO but conspicuously enough the Borland Developer Studio 2006 documentation (as well as the documentation for previous versions) says absolutely nothing about Data Link properties and creating .UDL files. However, there are features in the IDE to make it easy to create Data Link (..udl) files; we will come back to address these later in this article. Let us first create a UDL file manually and specify the Connection object to use it instead of using a hard-coded Connection String.

    To create a new Data Link file, browse to the project folder or DataLink folder in explorer, right-click and from the context menu select New|Text Document. Name it Test1.txt. Rename the file to change the extension to .udl instead of .txt; the file name should now be ADOConnectProj.udl. Make sure that the extension has actually been changed; often, when you try to change the file extension from within Windows what happens is that the file name (the first part ) is changed and the desired extension is added to it while the real extension remains unchanged. This would mean that you end up with something like ADOConnectProj.udl.txt so that the file type never changes. In such circumstances I always go back to the Command prompt and use "Ren" to not only change the filename but the extension as well.

    Double-click on the file to bring up the Data Link Properties dialog. The Microsoft OLEDB Provider for ODBC Drivers is selected by default in the Providers tab. Click on the Connection tab; you will require a valid ODBC DSN (Data Source Name) to connect to the database. If you haven't already created a DSN for the database, read the next section which demonstrates how to create a new DSN from the ODBC administrator in the control panel.

    More Delphi-Kylix Articles
    More By Danish Ahmed


     

    DELPHI-KYLIX ARTICLES

    - Client Dataset: Working with Data Packets an...
    - Using the Client Dataset in an N-Tiered Appl...
    - Using the Client Dataset in Two-Tiered Clien...
    - Using the Client Dataset in File-Based Archi...
    - Demystifying the Client Dataset
    - Working with INI Files in Delphi
    - Creating Data Link (UDL) Files in Delphi
    - Looking at the Details for an Invoicing Appl...
    - Invoicing in Delphi: Show Me the Money
    - Saving Images and Binary Files to a Database...
    - Saving Files to a Database using Delphi: Sav...
    - Creating CF Applications and Integrating a S...
    - Using Try and Finally to Help Prevent Memory...
    - The Implementation of an FTP Server
    - FTP Server: The Theory






    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway