Showing posts with label MFC. Show all posts
Showing posts with label MFC. Show all posts

20061219

MFC and SQLFetch

This is probably an old bug, but nevertheless one that cost me a few hours. When using a recordset in MFC 4.2 (comes with Visual Studio 6) and an odbc driver, do not open the recordset with a sql statement. That forces the first parameter in the open to be default (or dynaset which is the same). With a dynaset, MFC decides to call SQLExtendedFetch, like here

AFX_ODBC_CALL(::SQLExtendedFetch(m_hstmt, wFetchType, nRow, pdwRowsFetched, m_rgRowStatus));

And guess what ? SQLExtendedFetch returns the number of rows fetched, which AFC_ODBC_CALL freely interprets as an error code. Sure, your saying, who's using MFC4.2 now, or why not just change the source code ? All valid points, but after all, most people use the out of the box stuff, even nowadays.

All right, nuff said