Stored procedure call in method with OperationBehavior attribute: problems with transactions
- by Gerrie Schenck
I'm using ADO.Net's ExecuteNonQuery to call a stored procedure, works like a charm stand-alone but when implementing it where it should be called I'm running into problems concerning transactions.
For example
System.Data.SqlClient.SqlException: Transaction count after EXECUTE indicates a
mismatching number of BEGIN and COMMIT statements. Previous count = 1, current count = 0.
and also a timeout right after that.
I've just found out the method which calls the stored procedure is marked with the following WCF attribute:
[OperationBehavior(TransactionScopeRequired = true, TransactionAutoComplete = true)]
How will this influence the call my stored procedure? How can I tell .Net to execute the stored procedure outside this transaction?
The stored procedure contains insert statements and also a transaction, but removing them doesn't change the behavior...