Thursday, November 27, 2008

Adding a DSN to a Machine using Visual Basic .NET Code

Click the link to download the GUI version of the source code for this post

Click the link to download the Console version of the source code for this post

Licensing and Warranty

You may use the code as you wish - it may be used in commercial or other applications, and it may be redistributed and modified. The code is provided "as-is". No claim of suitability, guarantee, or any warranty whatsoever is provided. By downloading the code, you agree to defend, indemnify, and hold harmless the Author and the Publisher from and against any claims, suits, losses, damages, liabilities, costs, and expenses (including reasonable legal or attorneys' fees) resulting from or relating to any use of the code by you.

While it is relatively simple to manually add a DSN to a machine, you may have a project where you have to automatically add a DSN to a machine. For example, I was working on a PC-based application project (including the setup and deployment package) that used a DSN on the user's PC to connect to the data source. My user base wasn't the most technically savvy bunch, so I wanted to make their user experience easier by automatically creating the DSN for them. Using .NET, you can create a program that will automatically create a DSN on a machine.

I have two sample versions of this application. The first sample is using a GUI application to perform the process. The second sample is using a console application to perform the process. You can download one or both of these samples by clicking on the links at the top of the post. I also published an instructional document on Scribd that you may also use for your reference.


No comments: