Monday, April 07, 2008

Building Connection Strings Visually

Ever run into a situation where you need to generate a connection string for a database and forget how to write them? I know I do. I can pretty much do an Access db connection string in my sleep and also SQL Server connection strings, but anything outside of those, I just guess and have to go to connectionstrings.com.

Well, I'm here to tell you that there is an insanely easy way to get this functionality without an internet connection or deep digging in help files.

  1. Simply right click on your desktop
  2. Choose "New" then click on "Text File".
    This will create a text file on your desktop and allow you to edit the name.

  3. Name the file cheat.udl (the key here is the udl extension).
  4. Now, double click on the file. :)Once you've configured the connection using the dialog, just click OK. Once you're back on your desktop, simply right click on the UDL file and view it in Notepad. You should see the connection string and it's easy to copy / paste it into your code.
OK, I have to give props where props are due; Issam turned me onto that cool trick a few years ago. I always forgot about this trick until I had to build a connection string. Well, now I'm sharing it for all to see. Pretty cool huh?

No comments: