Friday, 9 April 2010

Testing a database connection or Who the hell (UDL) are you?

If you work with software and databases then it wont be long before you encounter  problems connecting to SQL server (or any other data source) and there are often many reasons why you would be presented with  problems. A good way of starting to analyse your problems with no need for any specific software on a  PC is to use a UDL file.

Create a new text file on the desktop of the computer you are using. Rename this file with a udl extension, something like test.udl will be ideal. All you need do is double click this and a Data Link Properties dialog opens. For some reason this always opens on the wrong tab so make sure you select to the Provider tab and then choose the OLE DB provider applicable to your problem. Next move to the Connection tab and move through the required steps, entering a data source name, whether you want to use Windows or specify SQL login details and finally the database name you wish to connect to. Once this is complete press the Test Connection button and see what results you get.

You may get a 'test succeeded' message in which case there is no reason why any other means of connecting from this computer wont work and if they do then its something wrong with the settings in the other application you are using. Alternatively you may get a message detailing why the connection failed. This is the key, you get a message detailing the issue and this lets you investigate and resolve your problem.

IMPORTANT:
Remember to delete the udl file once you have used it as, if you have entered a username and password then this is saved in plain text with no security and could pose a security risk. All that is required is for the udl file to be renamed to txt and the username and password can be accessed by notepad or any other text reading software.


Please be sure to read the code disclaimer page before you use any code in this blog.

1 comment:

Adam said...

A really useful post - thanks for the explanation.

AddThis

Bookmark and Share
 
Google Analytics Alternative