Home | Overview | How Do I | FAQ | Sample | Tutorial | ODBC Driver List
The database classes provide a simpler interface to a data source than does ODBC. As a result, the classes don’t encapsulate all of the ODBC API. For any functionality that falls outside the abilities of the classes, you must call ODBC API functions directly. For example, you must call the ODBC catalog functions (::SQLColumns, ::SQLProcedures, ::SQLTables, and others) directly. Samples of direct ODBC function calls used with the classes are in the MFC Database sample CATALOG.
Note ODBC data sources are accessible through the MFC ODBC classes, as described in this article, or through the MFC Data Access Object (DAO) classes. For information about the DAO classes, see the article DAO and MFC.
To call an ODBC API function directly, you must take the same steps you’d take if you were making the calls without the framework. They are:
Member variables CDatabase::m_hdbc and CRecordset::m_hstmt are available so that you do not need to allocate and initialize these yourself.
For more information about these steps, see the ODBC SDK Programmer’s Reference on the MSDN Library CD.
In addition to these steps, you need to take extra steps to check function return values, assure that your program isn’t waiting for an asynchronous call to finish, and so on. You can simplify these last steps by using the AFX_SQL_ASYNC and AFX_SQL_SYNC macros. See Macros and Globals in the Class Library Reference for information.
See Also ODBC