You can run the Convert DSN Demo sample by building the debug or nondebug version and double-clicking the \Samples\Odbc\Convdsn\Ndebug32\Convdsn.exe or \Samples\Odbc\Convdsn\Debug32\Convdsn.exe file in Windows Explorer, or by clicking Start, and then Run, and typing \<path>\Convdsn.exe.
The ODBC 3.51 Driver Manager has an improved tracing mechanism that allows developers to implement their own trace DLLs. These can be used to provide more information than the standard driver manager trace DLL (Odbctrac.dll).
The standard trace DLL is a part of the ODBC 3.51 redistributable components, and ODBC vendors are required to ship this DLL unmodified from the original source whenever they ship ODBC core components. However, it is possible to also develop and ship a custom trace DLL to provide more functionality than the standard one.
To get the driver manager to use an alternative trace DLL, use the ODBC Administrator to set the trace DLL path and name.
This will cause the driver manager to use your custom trace DLL. If this key is not defined, the driver manager uses the standard trace DLL (Odbctrac.dll).
A trace DLL must export an entry point named TraceSQLxxxx for each ODBC 3.5 function, where xxxx is the name of the function (TraceSQLConnect, for example). This trace function will be called upon entry to the ODBC function. Trace functions take as arguments the standard arguments for the ODBC function, but they return a "magic cookie" that the driver manager will pass back to the trace DLL when the function exits.
In addition to the TraceSQLxxxx functions, a trace DLL must export the following:
The prototypes and definitions of these functions are in DoTrace.c.
Note For security purposes, the trace DLL must be installed in the Windows system (or System32) directory. The driver manager will refuse to use a trace DLL from any other directory. This prevents users from installing the trace DLL on locked-down systems.
To use this sample trace DLL, copy STRACE.DLL to the System directory and use the ODBC Administrator (Odbcad32) to select Strace.dll as your custom DLL.
The batch file in this directory (Odbcpm.bat) will enable performance monitoring counters for ODBC connection pooling. Connection pooling allows one application to reuse open connection handles, which saves round-trips to the server. When the application calls SQLDisconnect with a connected handle, the driver manager adds the connection to a list of free connections for that driver or environment. When SQLDriverConnect or SQLConnect is called with a connection string and connection options that are compatible with the pooled connection, the driver manager will return this pooled connection to the application.
If no compatible requests are made within the timeout period specified for that driver, the pooled connection will actually be disconnected from the driver. The timeout period for the driver is specified in the registry under HKEY_LOCAL_MACHINE\SOFTWARE\Odbc\Odbcinst.ini\DriverName\CPTimeout.
Connection pooling is typically used for Web server applications, which tend to create many short-lived connections.
To enable performance monitoring, run odbcpm enable. To disable monitoring, run odbcpm disable.
To see the counters, run the perfmon program. Select the ODBC Connection Pooling object.
For more information, see SQL_ATTR_CONNECTION_POOLING under SQLSetEnvAttr in this guide.