BUG: "No Corresponding BEGIN TRANSACTION" Error When COMMIT TRANSACTION Is Run (810100)
The information in this article applies to:
- ActiveX Data Objects (ADO) 2.7
- Microsoft Visual Basic Enterprise Edition for Windows 6.0
- Microsoft Visual Basic Learning Edition for Windows 6.0
- Microsoft Visual Basic Professional Edition for Windows 6.0
SYMPTOMSWhen you call a recursive SQL Server stored procedure from
an ADO application by using ODBC CALL syntax in a TRANSACTION, you may receive
the following error message when COMMIT TRANSACTION is run: The COMMIT TRANSACTION request has no corresponding BEGIN
TRANSACTION. (Microsoft OLE DB Provider for SQL Server) CAUSEADO causes Microsoft SQL Server to run the stored procedure
on two occasions. First, it runs the procedure with SET FMTONLY set to ON. When
SET FMT ONLY is set to ON, SQL Server always exceeds the maximum nesting level
(32) irrespective of the parameter that is passed. Therefore, SQL Server aborts
the batch, and rolls back the TRANSACTION. Because the SQL Server internally
runs this method, no error is reported. SQL Server runs the stored procedure
again. This time, depending on the parameter that is passed, the execution of
the stored procedure occurs.
When this second execution of the stored
procedure exceeds the 32-level limit, the correct error message is returned.
When the correct execution of the stored procedure does not exceed the nesting
level maximum, you receive the error message that is described in the
"Symptoms" section. This occurs when COMMIT TRANSACTION is run. It is run
because SQL Server rolled back the TRANSACTION when the maximum nesting was
exceeded, and SQL Server aborted the batch. RESOLUTIONTo work around this problem, do not call the stored
procedure by using ODBC Call syntax. You can call the stored procedure in may
ways by using ADO. One of the methods is to call a stored procedure by using a
command object. The following is an example: ' Command to execute the stored procedure
Dim cmd As ADODB.Command
Set cmd = New ADODB.Command
With cmd
' Specify the command type as Stored Procedure
.CommandType = adCmdStoredProc
' Specify the Stored Procedure to call
.CommandText = "RecursionTest"
' Specify the Connection to be used
Set .ActiveConnection = cn
' Set up new parameter for the stored procedure
Dim prm As Parameter
Set prm = cmd.CreateParameter("@Param", adInteger, adParamInput, , -35)
.Parameters.Append prm
' Execute the Stored Procedure
.Execute
End With
Set cmd = Nothing STATUS Microsoft has confirmed that this is a
bug in the Microsoft products that are listed at the beginning of this article.
REFERENCESFor more information, visit the following MSDN Web site:
Modification Type: | Major | Last Reviewed: | 5/20/2003 |
---|
Keywords: | kbStoredProc kbSQLProg kbDatabase kbClient kberrmsg kbBug KB810100 kbAudDeveloper |
---|
|