Essential Developer Tools - Part 3: UDL Files
One thing about being a developer is that at some point you will have to work with databases and datastores. It’s a fact of life (like death and taxes). The thing about these databases is that they all require connection strings to access them—but the problem is, how do you get the connection string? A popular website is http://www.connectionstrings.com, which lists them, and you can then copy, paste, and modify those for your own needs. However, there’s a problem with this: it’s open to errors during modification (even if you can copy and paste without error), and there’s no built-in test system for your environment.
Well, fear not—Windows (I’ve known about this since Windows 2000 and can confirm it works on XP, Vista, and 2003) has a great feature for finding out connection strings and testing them. Here’s how you do it:
- Create a new empty file somewhere (the desktop is good, because you can right-click → New → Text Document).
- The trick is to ensure the file extension is
.udl(e.g., connection.udl). - Double-click the file and use the (possibly) familiar connection wizard/ODBC dialog to set and test the values.
Once you click OK, the window disappears. But here’s the good part: if you now open that file in Notepad, you’ll find the connection string in plain text—complete with all the correct values for your environment!
Happy connecting!
Update (10 Jan 2008): If you’re doing this on x64 machines and encountering issues, this may help: http://blogs.msdn.com/snehadeep/archive/2008/01/10/running-a-32-bit-data-link-properties-udl-in-64-bit-box.aspx.