0

I am using Enterprise Library's Data Access Block.

My code is doing large batch updates, but for one of our customers it always ends up failing with one of the following exceptions:

System.ArgumentOutOfRangeException: The StatementType enumeration value, 4, is invalid.
Parameter name: StatementType
at System.Data.Common.DbDataAdapter.UpdatedRowStatusErrors(RowUpdatedEventArgs rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount)
at System.Data.Common.DbDataAdapter.UpdatedRowStatus(RowUpdatedEventArgs rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount)
at System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows, DataTableMapping tableMapping)
at System.Data.Common.DbDataAdapter.UpdateFromDataTable(DataTable dataTable, DataTableMapping tableMapping)
at System.Data.Common.DbDataAdapter.Update(DataSet dataSet, String srcTable)

and

System.InvalidOperationException: Invalid operation. The connection is closed. at
System.Data.Common.DbDataAdapter.UpdatedRowStatusErrors(RowUpdatedEventArgs rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount) at
System.Data.Common.DbDataAdapter.UpdatedRowStatus(RowUpdatedEventArgs rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount) at
System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows, DataTableMapping tableMapping) at
System.Data.Common.DbDataAdapter.UpdateFromDataTable(DataTable dataTable, DataTableMapping tableMapping) at
System.Data.Common.DbDataAdapter.Update(DataTable dataTable) at
Microsoft.Practices.EnterpriseLibrary.Data.Database.DoUpdateDataSet(UpdateBehavior behavior, DataSet dataSet, String tableName, IDbCommand insertCommand, IDbCommand updateCommand, IDbCommand deleteCommand, Nullable`1 updateBatchSize) at
Microsoft.Practices.EnterpriseLibrary.Data.Database.UpdateDataSet(DataSet dataSet, String tableName, DbCommand insertCommand, DbCommand updateCommand, DbCommand deleteCommand, UpdateBehavior updateBehavior, Nullable`1 updateBatchSize) at
Eldritch Conundrum
  • 8,452
  • 6
  • 42
  • 50

1 Answers1

2

I have searched the internet for a while, without being able to find what these errors mean or how to fix them. Now that I have finally found the answer, I am sharing it.

The errors always occurred after 10 minutes. It was actually a timeout.

Raising the value of my transactionScope.TransactionOptions.Timeout didn't help; checking if MSDTC was correctly configured didn't help either.

I got it to work by inserting the following:

<system.transactions>
    <machineSettings maxTimeout="20:00:00"/>
</system.transactions>

into the machine.config files that can be found here:

C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config

Hope this helps someone, someday...

Eldritch Conundrum
  • 8,452
  • 6
  • 42
  • 50