English version of all error messages you can encounter while programming
  |   ABOUT


Solution for "The transaction associated with the current connection has completed but has not been disposed. The transaction must be disposed before the connection can be used to execute SQL statements."



This error relates to the .Net Framework when doing a connection to a database, using a transaction.

1. You hit the timeout, increase the transaction timeout to avoid premature ending

using(TransactionScope scope =newTransactionScope(TransactionScopeOption.Required,newSystem.TimeSpan(0,15,0))){// The current example sets the transaction timeout to 15 minutes, increase it to reflect your needs}

It can also be necessary to increase the setting in the machine.config file, like this

<machineSettingsmaxTimeout="00:15:00"/>

https://stackoverflow.com/questions/11453066/error-the-transaction-associated-with-the-current-connection-has-completed-but/14587635#14587635

2. If you insert tons of data, you should consider BULK INSERT

If you hit a transaction timeout while doing tons of INSERT statements, you should consider using a BULK INSERT command to speed up the process.

https://stackoverflow.com/questions/13858837/bulk-insert-of-generic-list-c-sharp-into-sql-server/43269950#43269950




Localized versions of this error

Transakce přidružená k aktuálnímu připojení byla dokončena, ale nebyla vyřazena. Aby mohlo být připojení použito k provedení příkazů SQL, musí být transakce nejprve vyřazena.
 
La transacción asociada con la conexión actual se ha completado, pero no se ha eliminado. Debe eliminarse antes de utilizar la conexión para ejecutar instrucciones SQL.
 
Transakcja skojarzona z bieżącym połączeniem została zakończona, ale nie została usunięta. Należy usunąć transakcję, aby można było używać połączenia w celu wykonywania instrukcji SQL.
 
Transaktionen som är associerad med den aktuella anslutningen har slutförts men inte tagits bort. Transaktionen måste tas bort innan anslutningen kan användas för att köra SQL-satser.
 
Geçerli bağlantıyla ilişkili işlem tamamlandı ancak atılmadı. Bağlantının SQL deyimleri yürütmek amacıyla kullanılabilmesi için işlemin atılması gerekiyor.
 
与当前连接相关联的事务已经完成,但尚未释放。必须先释放该事务,然后才能使用该连接来执行 SQL 语句。
 
與目前連接關聯的交易已完成,但尚未處置。必須先處置交易,才能使用連接來執行 SQL 陳述式。

Disclaimer
Those solutions have been provided to you without any guarantee, they have been found on different help forums and brought to you here to ease your resolution process.







Copyright © dotmedias 2012 Launched in 2012, to help programmers finding solutions