PRB: ADO EOF Returns True on SQL Server 7.0, Returns Time-out Error on SQL Server 6.5 (252405)
The information in this article applies to:
- Microsoft Data Access Components 2.1
- Microsoft Data Access Components 2.5
- Microsoft Data Access Components 2.6
- Microsoft Data Access Components 2.7
- Microsoft SQL Server 6.5
- Microsoft SQL Server 6.5 Service Pack 1 and later
- Microsoft SQL Server 7.0
This article was previously published under Q252405 SYMPTOMS When you open an ActiveX Data Objects (ADO) recordset with
pessimistic locking on already locked data and then check the recordset for the
EOF property, you receive different results on Microsoft SQL Server
6.5, Microsoft SQL Server 7.0, and Microsoft SQL Server 2000. With Microsoft
SQL Server 6.5, a time-out error is thrown at the ADO recordset Open call. When
you use Microsoft SQL Server 7.0 or Microsoft SQL Server 2000, the Open call is successful and EOF checking returns True and no error is thrown. CAUSE This discrepancy occurs because the computer running SQL
Server 6.5 is not sending the Tabular Data Stream (TDS) packets back the same
way that the computer running SQL Server 7.0 is. As a result, the provider is
reacting accordingly.
When you execute the rs.Open call, SQL Server 6.5 makes two Netlibrary API calls together; one to sp_cursoropen, and the other to collect metadata for the returning rowset. The sp_cursoropen call comes back immediately (and successfully) but the following
call to get metadata is blocked on the server and the connection times out.
Because these two calls are executed as a unit, then the entire rs.Open call fails and the time-out error is returned.
With
SQL Server 7.0, these two calls are also issued together, but the call to get
metadata is not blocked on the server because it is more optimized in this
regard, and doesn't block the metadata. In addition, because they both execute
successfully together, then the call to rs.Open completes without error. When EOF is called, ADO does no error
checking on whether the data is actually locked in this method, and thus no
error is raised. ADO is satisfied until it actually has to retrieve the data
with a call to sp_cursorfetch and it finds that the records are locked, and then the error is
thrown.
Any back-end server that can separate cursor creation and
metadata from the actual data retrieval usually displays the same behavior on
EOF calls as that of SQL Server 7.0. RESOLUTION Because EOF is not the place to return errors, you need to
either employ a MoveFirst method, or directly reference the recordset so you can detect the
lock on the data.
One recommendation is to check rs.Status (which internally calls MoveFirst), because it returns the time-out error if there is one, and
barring time-out errors, also truthfully notifies you if EOF/BOF returns True, and gives you the status of the recordset. STATUS This behavior is by design. REFERENCES (c) Microsoft Corporation 1999, All Rights Reserved.
Contributions by Rick Anderson, Microsoft Corporation.
Modification Type: | Major | Last Reviewed: | 11/4/2003 |
---|
Keywords: | kbDatabase kbprb KB252405 kbAudDeveloper |
---|
|