Here is step-by-step how to create an ODBC DSN automatically through client/server application setup project in your client computer so you don’t need to adding and configure an ODBC connection manually in every client computer to support your client/server application. For your information, I’m using Windows Vista Home Premium SP1, SQL Server 2005 and VB.NET 2005 SP1.

1.  Open new blank text file using Notepad (I’m using Notepad++), write:

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\ODBC\ODBC.INI\ODBC Data Sources]
“your_user_dsn_name”=”SQL Native Client”


2.  Save the file by using .reg extension
3. Open another brand new blank text file the write:

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\ODBC\ODBC.INI\your_user_dsn_name]
“Driver”=”C:\\WINDOWS\\system32\\sqlncli.dll”
“LastUser”=”your_sql_database_engine_username”
“Database”=”your_database_name”
“Description”=”your_database_connection_description”
“Server”=”your_database_server_name_or_ip_address”


3.  Save the file by using .reg extension
4.  Now, you have 2 .reg files on your machine, go to your Project
5.  Under Visual Studio Solution Explorer, right click your Setup Project – View – Registry
6.  On Registry window, right click Registry on Target Machine – Import
7.  Choose your first .reg file you have just created before then click OK
8.  Do the same step for the second .reg file
9.  Finish, save your project

Quite simple isn’t it?

Advertisements