Building connection STRINGS by using a UDL file


A UDL file brings up the Data Link Properties dialog box for testing a connection or building a connection string for you. It's very handy. This article explains how to build connection Strings using a UDL file.

All you need to do is create a UDL file. It's so useful I have a UDL file on the desktop of all of my machines.

Start by creating a text file on your desktop or wherever you want.

Select the entire file name including the txt file type (this means that your machine must be configured to show the extension) and change the name and file type to test.udl or connection.udl or whatever you prefer.

Now you have a UDL file on your desktop:

Double-click the UDL file to bring up the dialog box. By default it appears as shown above. It isn't limited to just SQL Server connection strings. It works for all of your OLE DB data providers as you can see on the provider tab. Notice that in the screen capture below, Oracle's provider appears.

It gets even better! Once you've successfully tested your connection, click OK to save your connection string into the UDL file. Open the UDL file in a text editor and you'll find your fully constructed connection string. For example:
[oledb]
; Everything after this line is an OLE DB initstring
Provider=SQLOLEDB.1;Persist Security Info=False;User ID=cookjp;Initial Catalog=SomeOtherDb;Data Source=SRV2
In this example, SQL Server authentication was used. Notice that for security purposes, the password was not persisted into the UDL file. If you check Allow saving password on the Connection tab of the Data Link Properties dialog box, it will save the password into the connection string in the UDL file after displaying this warning:

You can drag your UDL file to a Visual Studio project to get the connection string:


Comments

No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: