0

我正在使用企业库的数据访问块。

我的代码正在进行大批量更新,但对于我们的一位客户来说,它总是以下列异常之一告终:

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)

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
4

1 回答 1

1

我已经在互联网上搜索了一段时间,但无法找到这些错误的含义或如何修复它们。现在终于找到答案了,分享一下。

错误总是在 10 分钟后发生。这实际上是一个超时

提高 my 的价值transactionScope.TransactionOptions.Timeout没有帮助;检查是否正确配置了 MSDTC 也无济于事。

我通过插入以下内容使其工作:

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

进入可以在这里找到的machine.config文件:

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

希望这对某人有所帮助,有一天......

于 2013-03-13T16:28:14.640 回答