[英]The transaction must be disposed before the connection can be used to execute sql statements
我收到了這個錯誤
必須先處理事務,然后才能使用連接執行sql語句。
我有一個包含大約6000行的Excel文件,我將這些文件上傳到類型化數據集中的數據表中,然后我嘗試在dt中的這些行上應用我的業務邏輯。
從第二個循環拋出的異常,我必須做兩個循環; 為什么會發生這種異常,我該如何解決?
這是我的代碼:
try
{
using (TransactionScope scope = SysInfo.BeginTransaction(IsolationLevel.Serializable))
{
//Here is my Typed dataset
//Method Looping through row in Datatable & Calling DB
//another Method Looping through row in Datatable & Calling DB
scope.Complete();
}
}
catch (Exception ex) { throw ex; }
我通過在App.config中添加以下行來解決它:
<configuration>
<system.transactions>
<defaultSettings timeout="00:01:30" />
</system.transactions>
</configuration>
這在Machine.config中:
<configuration>
<system.transactions>
<machineSettings maxTimeout="00:01:30" />
</system.transactions>
</configuration>
由於這個過程需要很長時間超過10分鍾,所以我發現我需要用更高的值覆蓋這個值。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.