ODBC Data Source ADministration

Submitted by date of submission user level 

Mahesh Chand Nov 30, 2000 Beginner 

Creating an ODBC Data Source is not a big deal. But it might be a big deal for beginners as I have got couple of mails from them and they have asked me how to create an ODBC data source. So here I am.

You need to understand ODBC Admin before creating an ODBC data source. I have latest ODBC 3.51 version and OS is Window NT 4.0. The ODBC Data Source Administrator dialog looks like this:

ODBC Admin and Windows Registry

First dialog of ODBC Admin looks like this:

All data of ODBC Admin get stored in the Windows registry. User DSNs get stored in the registry under the key HKEY_CURRENT_USER\SOFTWARE\ODBC There is one key corresponding to each DSN which lots of key/value pair as shown in the picture below. 

Rest of the information of the ODBC Admin is stored in the HKEY_LOCAL_MACHINE\SOFTWARE\ODBC. It has two sub folders ODBC.INI and ODBCINST.INI. 

ODBC.INI stores information about File and System DSNs. 

Rest of the information such as ODBC driver names, files, versions, time out for each driver etc is stored in the key ODBCINST.INI.

 

ODBC Data Source Administator Options

UserDSN: 

This is the type of DSN you will be creating for most of your applications. Only current user of this machine can see these DSNs. Add button is used to create a new DSN, Remove button is used to delete an existing DSN, and Configure is to reset the configuration of a DSN.

System DSN: 

This type of DSNs are available to all users on this machine including NT Services.

File DSN:

This type of data sources are shared by the users who has same drivers installed.

Drivers:

This dialog shows all available ODBC drivers on this machine with its version, company name, and corresponding file. You can use this dialog to find out the driver version.

Tracing: 

This is a new option in 3.51 version. This option is allows you to create a log file for driver's calls. This option also can be used to write your VC++ TRACE macro into a log file during debugging of your application.

Connection Pooling:

This is also a new addition in 3.51 version. This option let you reused the open ODBC connection to save time.

About: 

About dialog displays your information about ODBC Admin including file ( dll ) name and its versions.

 

Creating an ODBC DataSource

You need an ODBC Data Source to use ODBC in your application. You create ODBC data source from ODBC Administration. You can call ODBC Admin from Control Panel.

Click Add to create a new Data Source. You get this dialog. Select your database type. I have an access database so I pick Microsoft Access Driver(*.mdb).

Next dialog asks you to put Data Source Name and Description. You can pick any name as your Data Source Name and corresponding description. Next step is to call your database. If you don't have any database, create database with some tables and data in it. Or download access database mcb1.krz attached with this article.

Pick your database and click Ok. Close the ODBC Admin dialog.

You will see your new DSN in the User DSN list.

About the Author:

Mahesh is Admin and the founder of this site. He has been programming in VC++, Visual Basic, COM, ATL, Database Programming for 4 years. He can be reached at Mahesh. His  background includes Master's in Computer Science and Applications and Batchelor's in Mathematics and Physics.