Microsoft KB Archive/111815

{|
 * width="100%"|

PRB: Visual C++ 1.5 ODBC Drivers Don't Support Dynasets

 * }

Q111815

-

The information in this article applies to:


 * The Microsoft Foundation Classes (MFC), included with:
 * Microsoft Visual C++, version 1.5

-

SYMPTOMS
An attempt to create a dynaset CRecordset object may cause a message box to appear with the following message:

Internal application error.

If the debug version of the Microsoft Foundation Class (MFC) library is used and TRACE diagnostics are enabled (see MFC Technical Note 7 "Debugging Trace Options" for more information), the following TRACE messages may appear in the Output window of the debugger:

ODBC driver does not support dynasets.

Warning: Throwing an Exception of type CDBException

Warning: Throwing an Exception of type CDBException

Warning: Uncaught exception in WindowProc (returning 0)

CAUSE
The ODBC (Open Database Connectivity) driver being used doesn't support dynasets. The ODBC drivers provided with Visual C++ version 1.5 don't support dynasets.

RESOLUTION
To use the dynaset attribute of a CRecordset object, you must acquire an ODBC driver that will support the features of a dynaset. MFC Technical Note 42 "ODBC Driver Developer Recommendations" lists the requirements for an ODBC driver if it is to be used for creating dynaset CRecordsets. They are:

  SQLGetInfo, SQL_ODBC_VER must return > "01". SQLGetInfo, SQL_SCROLL_OPTIONS must support SQL_SO_KEYSET_DRIVEN. SQLGetInfo, SQL_ROW_UPDATES must return "Y". SQLGetInfo, SQL_POSITIONED_STATEMENTS must support SQL_PS_POSITIONED_DELETE and SQL_PS_POSITIONED_UPDATE. In addition, if pessimistic locking is requested, a call to SQLSetPos with irow 1, fRefresh FALSE, and fLock SQL_LCK_EXCLUSIVE will be made.

MORE INFORMATION
The information below comes from the README.WRI file included with Visual C++ version 1.5, and discusses what needs to be done to enable dynaset support when using an ODBC driver that meets the requirements shown above.

CDatabase::Open forces loading of ODBC's cursor library with the ::SQLSetConnection SQL_ODBC_CURSORS call in dbcore.cpp, line 238. Forced loading of the cursor library ensures the SQL_SCROLL_STATIC scroll option is supported for snapshots, even if the underlying driver does not support scrolling.

In order to open a recordset as a dynaset, the driver must support SQL_SCROLL_KEYSET, and the forced loading of the cursor library must be changed to optional loading. This can be done by changing the scroll option argument in the ::SQLSetConnection call mentioned above from SQL_CUR_USE_ODBC to SQL_CUR_USE_IF_NEEDED. This will cause the cursor library to NOT be loaded if the underlying driver supports SQLExtendedFetch. Note that snapshots require either the cursor library to be loaded, or for the underlying driver to support SQL_SCROLL_STATIC. Additional query words: 1.50 2.50 technote tech note

Keywords : kb16bitonly kbDatabase kbMFC kbODBC kbVC kbprb

Issue type : kbprb

Technology : kbAudDeveloper kbMFC