Occasionally I will learn a new (or rather, new to me) trick for making a task easier and think, “Oh! How did I not know this before?” Those are usually the things I file away for a great quick tip blog, like this tip using a UDL file for a data connection test.
I was helping someone create and test connection strings on a remote VM and, unsure of what was installed on the remote machine, I needed a way for them to test a SQL database connection that didn’t require Management Studio or Visual Studio, and could be transmitted between us for comparison.
No Installation Needed
What a perfect use for a UDL file! UDL, or Universal Data Link files are perfect for creating and testing connection strings. If you have ever connected Entity Framework to a database, then the interface will look very familiar to you.
To try this yourself, just create a text file on the system you want to use the connection string from. Name it testconnection.txt, then after saving the file change the extension to testconnection.udl.
Open the file using the OLE DB Core Services, which may be your default for this file type.
Now you should see the connection options that can be pointed to your desired server and database.
Accessing the Connection String
Once you are able to successfully connect to the database, save the file and close the editor. Now you can send or share this file with anyone else needing the connection, or you can open using a text editor and view the actual connection string to be used in your configuration files.
UDL files are far from new technology, but hey, it doesn’t have to be new to be the right tool for the job!
Want to also learn how to reconcile non-default schemas in a Visual Studio Database project? Check out my previous blog that shows you how.