Locked Issue about transaction cookie

  • Wednesday, December 30, 2009 2:36 AM
     
     
    Hi, all

    when I connect to sql server using connection.Open(), I got following exception:

    TransactionAbortedExceptionThe transaction has aborted.
    TransactionPromotionExceptionFailure while attempting to promote transaction.
    SqlExceptionThe PROMOTE TRANSACTION request failed because there is no local transaction active.

       at System.Transactions.TransactionStateAborted.CheckForFinishedTransaction(InternalTransaction tx)
       at System.Transactions.EnlistableStates.Promote(InternalTransaction tx)
       at System.Transactions.Transaction.Promote()
       at System.Transactions.TransactionInterop.ConvertToOletxTransaction(Transaction transaction)
       at System.Transactions.TransactionInterop.GetExportCookie(Transaction transaction, Byte[] whereabouts)
       at System.Data.SqlClient.SqlInternalConnection.GetTransactionCookie(Transaction transaction, Byte[] whereAbouts)
       at System.Data.SqlClient.SqlInternalConnection.EnlistNonNull(Transaction tx)
       at System.Data.SqlClient.SqlInternalConnection.Enlist(Transaction tx)
       at System.Data.SqlClient.SqlInternalConnectionTds.Activate(Transaction transaction)
       at System.Data.ProviderBase.DbConnectionInternal.ActivateConnection(Transaction transaction)
       at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)
       at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
       at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
       at System.Data.SqlClient.SqlConnection.Open()


    I have never heared about sql transaction cookie before, any one have ideas on this? Thank you in advance!
    • Moved by Arnie RowlandMVP Monday, January 11, 2010 5:52 AM Better Forum (From:Transact-SQL)
    •  

All Replies

  • Wednesday, December 30, 2009 3:18 AM
     
     
    Thanks, Any idea how to resolve this issue?
  • Wednesday, December 30, 2009 3:43 AM
     
     

    it is .net web application, this code work fine in the past. this exception happened since yesterday, I guess some transaction not be released.

     SqlHelper.ExecuteNonQuery(MCore.Configuration.ConnectionStrings.Entry,
                        CommandType.StoredProcedure,
                        "SP_Name",
                        parameters.ToArray());


     public static int ExecuteNonQuery(string connectionString, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
            {
                if (connectionString == null || connectionString.Length == 0) throw new ArgumentNullException("connectionString");

                // Create & open a SqlConnection, and dispose of it after we are done
                using (SqlConnection connection = new SqlConnection(connectionString))
                {
                                    connection.Open();   // exception happened here

                    // Call the overload that takes a connection in place of the connection string
                    return ExecuteNonQuery(connection, commandType, commandText, commandParameters);
                }
            }

  • Wednesday, December 30, 2009 6:21 AM
     
     
    yes, I have try to re-start IIS but still have such issue, I think SQL Server must cached something.
  • Wednesday, December 30, 2009 9:41 AM
     
     
    yes, I have try to re-start the sql, still do not work. Thank you all the same for your kindly help!
  • Wednesday, December 30, 2009 5:02 PM
     
     
    Sorry, no other ideas. Perhaps this question may be asked in the Database Engine forum.
    Premature optimization is the root of all evil in programming. (c) by Donald Knuth

    Naomi Nosonovsky, Sr. Programmer-Analyst

    My blog
  • Wednesday, December 30, 2009 10:16 PM
     
     
    This is really a .NET question, not a SQL Server question.  You would get a better answer from the .NET forums.
  • Monday, January 11, 2010 5:25 AM
     
     Answered
    it should be an code issue of incorrect using transaction in  TransactionScope. it works after removed the TransactionScope statement.
  • Monday, January 11, 2010 6:10 AM
     
     
    This post looks like a duplicate to this thread.

    http://social.msdn.microsoft.com/Forums/en-US/windowstransactionsprogramming/thread/7f9501d5-d657-482b-b10f-c989be9c7899

    "You cannot do a kindness too soon because you never know how soon it will be too late." -Ralph Waldo Emerson