Click to open or copy the ODBCINFO project files.
The ODBCINFO sample shows how to determine various ODBC driver capabilities at run time. ODBCINFO opens a selected ODBC data source and displays information about it in a set of property pages. The types of information displayed include:
ODBCINFO calls the SQLGetInfo function for every return type except handle values, then displays the results. Since SQLGetInfo is called repeatedly in the program, helper functions are defined that assist in calling SQLGetInfo and in formatting the returned data. These functions are static members of the CMyPage class, which is the common base class for all of the property page classes that are used to display data source information.
ODBCINFO also illustrates how to use property pages as the main window of an application.
Running the Sample
When you run ODBCINFO, select whether you want to load the ODBC cursor library using the Use Cursor Library check box. The ODBC cursor library provides static cursors for ODBC drivers that do not supply them. By checking or unchecking this check box, you can view the driver capabilities with or without the cursor library being present.
Select the Use Cursor Library check box if desired, click Data Source, and select an ODBC data source that you want to view. The property pages are populated with information from the selected data source.
ODBCINFO uses a CRecordset-derived class called CGetTypeInfo that wraps the SQLGetTypeInfo ODBC API function to determine the data types that a particular driver supports. CGetTypeInfo is taken from the catalog recordsets (Catsets.cpp) in the CATALOG2 sample.
Using a Property Sheet as the Main Window of an Application
The main window of ODBCINFO is a property sheet. There are issues to be aware of when doing this. First, by default, you cannot minimize a property sheet. ODBCINFO allows this by modifying the window styles and system menu in the property sheet’s OnInitDialog function after calling the base class. Second, you should consider how to associate icons with the application. For Windows 95, this is accomplished by changing the PROPSHEETHEADER structure of the property sheet before calling DoModal. ODBCINFO does this in the application’s InitInstance function. To get the application to display as an icon when minimized on Windows NT, the application needs to draw the icon when it is minimized. This is done in ODBCINFO by overriding the property sheet’s OnPaint, OnEraseBkgnd, and OnQueryDragIcon message handlers.