Managing ODBC System DSNs

Last updated: 14/02/99, Version 1.50.2
Changes from 1.50.1: Unregistering support added, recompiled with VC++ 6.0, samples updated


OdbcRegTool 2.0 with much extended functionality is available as commercial component, however, OdbcRegTool 1.51 as found on this page will be available for free forever.

Up to version 3, Internet Information Server has supported small CGI apps (dsnform.exe and newdsn.exe) for creating system datasources for ODBC via a web form. With IIS 4, these nice tools have disappeared - and I wasn't very happy with that!

Because I need the functionality to remotely create DSNs, I decided to create a small component to handle the task of creating a DSN for me - the OdbcRegTool component came into being. Since version 1.50.1, the component supports the ability to remove existing system datasources

With that component, you can create DSNs for all drivers that are installed on your computer. I have provided sample scripts for Excel, Access and SQL Server (the most popular one, I hope). So far, I haven't written any great frontend for the component, maybe someone else has the time to do it in DHTML??

There are two methods exposed, the most important one dedicated to creating new system datasources: CreateDSN. It takes as input the driver name (take a look in the ODBC control panel for that) and the string defining the DSN. Please see the examples above for how to form such a DSN (or look at the DSN entries in HKEY_LOCAL_MACHINE\Software\ODBC\odbc.ini, which show all the key/value pairs you might need for a given datasource).

The second method exposed is RemoveSysDSN. It takes as input the driver name (take a look in the ODBC control panel for that) and the string defining the DSN. For example:

Set xObj = Server.CreateObject("Softwing.OdbcRegTool")
strDriver = "Microsoft Access Driver (*.mdb)"
strDSN = "DSN=New Access Data Source" & vbNullChar
retval = xObj.RemoveSysDSN(strDriver, strDSN)
If retval = True Then 
    Response.Write "DSN deleted successfully." 
Else 
    Response.Write "Could not delete DSN."
End If

Installation and Download

Before using the component you have to register it using the regsvr32 utility: regsvr32 OdbcTool.dll.

Download (size is approx. 79KB)
The most current version number of the component is 1.51. It is compiled with Visual C++ 6.0 using MFC statically linked.

If you have comments or questions, don't hesitate to contact me: Christoph.Wille@softwing.com