Home arrow Delphi-Kylix arrow Page 5 - Creating Data Link (UDL) Files in Delphi
DELPHI-KYLIX

Creating Data Link (UDL) Files in Delphi


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.

Author Info:
By: Danish Ahmed
Rating: 5 stars5 stars5 stars5 stars5 stars / 8
August 06, 2007
TABLE OF CONTENTS:
  1. · Creating Data Link (UDL) Files in Delphi
  2. · Section 1: Adding a new ODBC Data Source
  3. · Section 2: Connecting with SQL Server Drivers
  4. · Section 3: Creating Data Link files programmatically
  5. · Section 4: More undocumented routines in ADODB

print this article
SEARCH DEVARTICLES

Creating Data Link (UDL) Files in Delphi - Section 4: More undocumented routines in ADODB
(Page 5 of 5 )

But that is not all, there a few more undocumented functions in the ADODB.pas unit which can help you avoid lengthy workarounds.

Procedure GetProviderNames(Names: Tstrings);

The GetProviderNames method can be used to fetch a list of all providers available.

Memo1.Clear;
GetProviderNames(Memo1.Lines);

Procedure GetDataLinkFiles (Names: Tstrings);

This function can be used to retrieve a list of filenames present in the DataLink folder (in my case the Data Link folder is in C:Program FilesCommon FilesSystemOle DB folder).

Memo1.Clear;
GetDataLinkFiles(Memo1.Lines);

Function PromptDataSource(ParentHandle: THandle; InitialString: WideString): WideString;

This function can be used to bring up the DataLink property dialog box and let the user provide the Data Source name. The PromptDataSource function returns the selected Data Source name as WideString.

var
ConxnStr:WideString;
begin
 
ConxnStr := PromptDataSource(Form1.Handle, ADOConnection1.ConnectionString);
  .....
end;

Function PromptDataLinkFile(ParentHandle: THandle; InitialFile: WideString): WideString;

This function returns the file name and its path as a string. It can be employed to let the user select the datalink to be used for connection.

var
dlfStr:WideString;
begin
 
dlfStr:=PromptDataLinkFile(Form1.Handle,'');
 
....
end;

Play around a little with these undocumented routines contained in the ADODB.pas unit file and you will find out how easy it is to create and manage ADO connections in your Delphi application without hard-coding the connection string or writing long and complicated codes.


DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

blog comments powered by Disqus
DELPHI-KYLIX ARTICLES

- Loading an XML Document into the DOM
- Delphi Wrapper Classes and XML
- Delphi and the DOM
- Delphi and XML
- Internet Access: Client Service
- Finishing the Client for an Internet Access ...
- The Client for an Internet Access Control Ap...
- User Management for an Internet Access Contr...
- Important Procedures for an Internet Access ...
- Server Code for an Internet Access Control A...
- Constructing the Interface for an Internet A...
- Building a Server Application for an Interne...
- Building an Internet Access Control Applicat...
- Client Dataset: Working with Data Packets an...
- Using the Client Dataset in an N-Tiered Appl...

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials