The ODBC cursor library provides the necessary basic cursor features: forward and backward scrolling, direct access by position, and positioned updates. In addition, ODBC has a cursor model that lets a properly written driver simulate a scrollable, updatable cursor — even though the underlying database does not.
Note There is little need for using the ODBC cursor library with the SQL Server ODBC driver because the SQL Server ODBC driver itself supports more cursor functions than the ODBC cursor library. The only reason to use the ODBC cursor library with the SQL Server ODBC driver is because the driver implements its cursor support through server cursors, and server cursors do not support some SQL statements (such as COMPUTE, COMPUTE BY, FOR BROWSE, or INTO).
The ODBC cursor library provides the following types of cursors.
Cursor type | Constants |
Static cursor | SQL_CURSOR_STATIC |
Forward-only cursor | SQL_CURSOR_FORWARD_ONLY |
Dynamic cursor | SQL_CURSOR_DYNAMIC |
Keyset cursor | SQL_CURSOR_KEYSET_DRIVEN |
You can control how the data source and the ODBC cursor library manage concurrency with the following locking options.
Locking type | Constant |
Read-only. Changes are not permitted. | SQL_CONCUR_READ_ONLY |
Optimistic concurrency using row versions. | SQL_CONCUR_ROWVER |
Optimistic concurrency using row values. | SQL_CONCUR_VALUES |
Uses the minimum locking sufficient to ensure that the row can be updated. | SQL_CONCUR_LOCK |
Care must be used with the ODBC cursor library because it caches the entire result set on the client computer, which can use large amounts of memory and reduce performance speed.
For More Information For more information on the ODBC cursor library, search online for "Using ODBC Cursors" and "SQLSetStmtOption" in MSDN Library Visual Studio 6.0. For more information on using locks to handle multiuser concurrency situations, see Managing Concurrency with Cursor Locks in this chapter.