【发布时间】:2011-05-18 18:31:29
【问题描述】:
所以我有一个类型化的数据集,我从另一个数据库创建了记录(超过 500,000 条记录!)。我需要将所有这些记录导入另一个数据库并具有以下代码(减去初始化、添加行等):
try
{
Console.WriteLine("Time to process of adding to table: Start at " + startDate.ToString() + " | End at " + DateTime.Now.ToString());
using (TransactionScope ts = new TransactionScope(TransactionScopeOption.RequiresNew, new TimeSpan(1, 0, 0)))
{
laborTicketTableAdapter.Update(laborTicket);
ts.Complete();
}
Console.WriteLine("Time to process transaction: Start at " + startDate.ToString() + " | End at " + DateTime.Now.ToString());
}
catch (SqlException ex)
{
MessageBox.Show("Something bad happened" + Environment.NewLine + ex.StackTrace);
result = false;
}
catch (Exception ex)
{
MessageBox.Show("Something bad happened" + Environment.NewLine + ex.StackTrace);
result = false;
}
控制台输出以下内容:
Time to process of adding to table: Start at 1/1/2009 2:05:59 PM | End at 5/18/2011 2:06:30 PM
The thread '<No Name>' (0xa5c) has exited with code 0 (0x0).
The thread '<No Name>' (0x2e4) has exited with code 0 (0x0).
The thread '<No Name>' (0xae0) has exited with code 0 (0x0).
A first chance exception of type 'System.Transactions.TransactionAbortedException' occurred in System.Transactions.dll
它抛出一个异常,内部异常是“事务超时”。事务已过期,因此我将超时设置为一小时,但在 15 分钟后仍然超时。怎么回事?
最后处理时间是下午 2:19:40,运行大约需要 15 分钟。我怎么会得到这个异常?我在控制台上看到三个线程,但这是一个空白项目中的空白。所有其他连接都关闭到外部数据源,当我进行更新时只剩下那个表适配器和表对象。
-- 编辑-- Machine.config 没有 maxTimeout 属性的任何设置
【问题讨论】:
标签: c# .net-3.5 transactions strongly-typed-dataset