"ODBC driver does not support dynamic recordset" error solved

xiaoxiao2021-04-03  227

I encountered a problem when using the VC to program. Code compilation passes, suddenly popping up a warning dialog box at runtime, as shown below:

I wonder where I have a problem. The only thing I think is likely to connect the database. So I found the code to connect the database:

M_PDatabase-> Open (NULL, FALSE, FALSE, "ODBC; DSN = Librarymis; UID = TXM; PWD = TXM");

Where m_pdatabase is a pointer for a CDATABASE class. So I checked MSDN and found the cdatabase's Open function. CDATABASE :: Open

virtual BOOL Open (LPCTSTR lpszDSN, BOOL bExclusive = FALSE, BOOL bReadOnly = FALSE, LPCTSTR lpszConnect = "ODBC;", BOOL bUseCursorLib = TRUE); throw (CDBException, CMemoryException);

I guessed the problem, I set the default value True in Bool Busecursorlib. I have to see what Busecursorlib means.

Busecursorlib

TRUE if you want the ODBC Cursor Library DLL to be loaded. The cursor library masks some functionality of the underlying ODBC driver, effectively preventing the use of dynasets (if the driver supports them). The only cursors supported if the cursor library is loaded are Static Snapshots and forward-only cursors. The default value is true. If you plan to create a recordset Object Directly from CrecordSet WITHOUT Deriving from it, you shouth not load the cursor library.

Big intending is to say that when BuseCurSorlib is True, the ODBC cursor library will be loaded. The cursor library covers some of the functions of the ODBC driver, effectively prevents the use of dynamic record sets (if the ODBC driver supports the use of dynamic record sets). If the optical label is loaded with a unique cursor, it is a static snapshot set and a unique forward cursor. The default value of the parameter is TRUE. If you create a CRecordset class object instead of inheriting from it, you should not load the optical library.

So the problem is to set the value of Busecursorlib to false. When I did this, the problem was solved.

转载请注明原文地址:https://www.9cbs.com/read-131477.html

New Post(0)