PRB: ODBCDirect Cursor Not Valid After Transaction Commits (217192)
The information in this article applies to:
- Microsoft Visual Basic Learning Edition for Windows 5.0
- Microsoft Visual Basic Learning Edition for Windows 6.0
- Microsoft Visual Basic Professional Edition for Windows 5.0
- Microsoft Visual Basic Professional Edition for Windows 6.0
- Microsoft Visual Basic Enterprise Edition for Windows 5.0
- Microsoft Visual Basic Enterprise Edition for Windows 6.0
This article was previously published under Q217192 SYMPTOMS
When you use ODBCDirect with Visual Basic, you receive the following error on accessing a recordset object that was created inside of a transaction that has been committed or rolled back:
3670 Cursor is not valid CAUSE
This error occurs because you are using server-side cursors on your connection and the cursor is being closed when the transaction is committed or rolled back. Whether a server-side cursor is closed on a transaction commit or rollback depends on the database driver that you are using. For the SQL Server driver, the default is to close the server-side cursor on the commit or rollback of a transaction.
RESOLUTION
When you use ODBCDirect, the only two workarounds are the following:
- Use client side cursors. (This only works with commit. Rollback will still cause the same error.)
- Requery the information (rs.requery) after a commit or rollback.
NOTE: For this workaround to work, MSDTC must not be running.
With some other data access APIs, such as RDO, you can manually set an option to preserve server-side cursors. You set this option using either the SQLSetConnectOption or the SQLSetConnectAttr ODBC API functions. These options must be set after the connection handle is allocated but before the connection has been made. With ODBCDirect it is not possible to have access to the connection handle before the connection has been established, so it is not possible to set the option.
STATUS
This behavior is by design.
REFERENCES
SQL Server 6.5/7.0 Books Online
For additional information, click the following article numbers to view the articles in the Microsoft Knowledge Base:
190109
HOWTO: Keep RDO Cursor Open After Transaction
Modification Type: | Major | Last Reviewed: | 11/5/2003 |
---|
Keywords: | kbprb KB217192 |
---|
|