Search This Blog

Connectionstrings... made easy!

posted on Tuesday, June 19, 2012

I don't know about you, but when I have to generate a new connectionstring I immediately get chills down my spine. Not because connectionstrings are incredibly difficult or complex but just because I always tend to get something wrong. This leads to me having to Google the correct syntax or browse through old projects to find a good example.

Sounds familiar? Well, today I've got a magic connectionstring tool and wait, before you click away after interpreting tool as virus-infected, advertisement overdoses, only half functioning shareware... I should probably add that you don't have to install anything, because this is something hiding in your very pc!

Curious yet?
You should be!

I only recently discovered this when a colleague showed me this. I was stunned by the fact that I never knew this and when I thought about it, I never read about this online or heard anybody mention it... . So, without further ado, I bring to you: the built-into-Windows-connectionstring-tool!

How does it work:
  1. Right-click in a random folder or on your desktop and create a new "Text Document".
  2. Change the extension of the file to .udl, you'll notice that Windows will recognize the extension as a "Microsoft Data Link"-file and will add a custom icon.
  3. Double-click the file to open the how-to-build-a-connectionstring-magic-interface.

The interface has four tabs: Provider, Connection, Advanced and All. Below you can find an image of each of these tabs. The name of the tab gives away which settings can be found there, but I'll sum them up for you anyway.

Provider: here you should select the type of provider for your datalink.
Connection: here you can browser a database server for databases. 

Advanced: here you can set some more advanced settings such as network security settings, timeouts and permissions.
All: all what's left can be found here, you can set properties for the type of data here.

If you have completed setting all the necessary data (normally only the settings in the connection tab will do) you can test the connection in the connection tab to be sure. If that test is successful, complete the wizard by pressing OK.

Right when you think you are now stuck with an entirely useful file, you should open this file in a text editor to witness the magic:

Your very own ready-to-use connectionstring!

Note: I have noticed that sometimes (in .NET-applications) you have to leave out the Provider-part.

So from know on you can go around and connect strings all over, have fun!

Could be useful, right?