PRB: Transactions and ADO Parameters Cause Connections to Hang (193095)
The information in this article applies to:
- ActiveX Data Objects (ADO) 1.0
- ActiveX Data Objects (ADO) 1.5
- ActiveX Data Objects (ADO) 2.0
- ActiveX Data Objects (ADO) 2.1 SP2
- ActiveX Data Objects (ADO) 2.5
- ActiveX Data Objects (ADO) 2.6
- ActiveX Data Objects (ADO) 2.7
This article was previously published under Q193095 SYMPTOMS
If you try to populate an ActiveX Data Objects (ADO) command object's
parameters collection, automatically from within a transaction, other
connections to the same SQL Server hang if they attempt to modify
information in the system tables of the TempDB database.
This behavior only occurs if you use the default ODBC provider for ADO in
conjunction with SQL Server version 6.5.
CAUSE
When an application attempts to populate the parameters collection of an
ADO command object automatically, it queries the system tables of the SQL
Server database for parameter-specific information (such as the total
number of parameters, the type of each parameter, the direction of each
parameter, and so forth). This information is returned to the calling
application through a temporary table created in the TempDB database of SQL
Server. The creation of a temporary table adds a record to the system
tables of the TempDB database.
If this is done from within a transaction, the addition of a record to the
system tables of the TempDB database results in the system tables of the
TempDB database being locked until the transaction has been either
committed or rolled back.
If a process on another connection to the SQL Server attempts to modify the
information in the system tables of the TempDB database, while the
database is locked by a preceding process, the process hangs until the
transaction is completed.
RESOLUTION
To avoid this behavior, you can implement either of the following two
programming concepts:
- You can manually populate the parameters collection (by explicitly
creating the parameter in your code and then appending that parameter to
the parameters collection of the command object). Because no trip to the
server is needed to define the parameters in the parameters collection
when manual population is used, no temporary tables need to be created
in the TempDB database (TempDB database is never locked by the
transaction).
- You can also continue to use the automatic population method, but you
should populate the parameters collection outside the scope of the
transaction.
STATUS
This behavior is by design.
REFERENCES
For additional information about Refreshing ADO Parameters for stored procedures, please see the following
article in the Microsoft Knowledge Base:
174223 HOWTO: Refresh ADO Parameters for a Stored Procedure
Modification Type: | Minor | Last Reviewed: | 3/14/2005 |
---|
Keywords: | kbDSupport kbprb kbStoredProc KB193095 kbAudDeveloper |
---|
|