The information in this article applies to:
SYMPTOMSWhen using a single command object to open multiple recordset objects, with one or more of those recordset objects open at the same time, you will encounter unexpected behavior. This is most notable when opening stored procedures with output or return parameters. CAUSEConsider the ActiveX Data Objects (ADO) code written in Visual Basic for Applications below:
At this point, the Parameters collection for the command object has two
objects, and you can reference them as you would normally. However,
consider the following code, which destroys (resets) the Parameters
collection:
At this point, the Parameters collection has been reset to contain only one
Parameter object. However, the original Recordset (rs1), which has not been
closed or released, still has a reference to an internal buffer that stores
the value of each parameter that was originally created. When the original
recordset is closed, it attempts to release the buffer. However, the second
recordset's Parameters collection may be using the same memory location for
its own buffers, and if both recordsets are trying to release the same
memory location, you could get an Access Violation.
The Access Violation has been confirmed to occur (at random intervals) when
using a forward only cursor with a parameterized stored procedure using the
OLE DB Provider for ODBC to the SQL Server ODBC Driver. It may occur with
other ODBC Drivers or OLE DB Providers as well.
The Access Violation appears to have been fixed in the MDAC 2.1 SP2 release. However, recycling the same Command Object for multiple, concurrently open Recordsets is not a safe practice. Any savings in performance or memory allocation you receive in minimizing the number of created objects will not be compensated for by increased risk of your code causing a failure within ADO. The Command Object is not designed or intended for this kind of utilization. STATUSThis behavior is by design. Additional query words:
Keywords : kbADO kbADO100 kbADO200 kbADO201 kbDatabase kbGrpVBDB kbGrpMDAC kbDSupport kbADO210sp2 kbMDAC210SP2 |
Last Reviewed: November 18, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |