CRecordset::snapshot doesn't work in VS2012 anymore - what's the alternative?

后端 未结 3 625
终归单人心
终归单人心 2021-01-14 09:04

Apparently, in VS2012, SQL_CUR_USE_ODBC is deprecated. [Update: it appears that the cursors library has been removed from VS2012 entirely].

MFC\'s CDatabase doesn\'

3条回答
  •  情书的邮戳
    2021-01-14 09:38

    Derive CDatabase and override OpenEx. In your derived class CMyDatabase, replace the call to AllocConnect to MyAllocConnect. Obviously, your MyAllocConnect function should call SQLSetConnectOption with the desired parameter:

    // Turn on cursor lib support
    if (dwOptions & useCursorLib)
    {
        AFX_SQL_SYNC(::SQLSetConnectOption(m_hdbc, SQL_ODBC_CURSORS, SQL_CUR_USE_ODBC));
        // With cursor library added records immediately in result set
        m_bIncRecordCountOnAdd = TRUE;
    }
    

    Then use your CMyDatabase class instead of CDatabase for all your queries.

提交回复
热议问题