I am getting this error
The transaction must be disposed before the connection can be used to execute sql statements.
i have an Excel file that contains about 6000 rows and I uploaded these file into Data table in typed dataset, then I am trying to apply my business logic on these rows in dt.
The exception throws from the second loop and I have to do two loops; why does this exception occur, and how can I solve it?
Here is my code:
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; }
I solved it by adding the below lines in App.config:
<configuration>
<system.transactions>
<defaultSettings timeout="00:01:30" />
</system.transactions>
</configuration>
and this in Machine.config:
<configuration>
<system.transactions>
<machineSettings maxTimeout="00:01:30" />
</system.transactions>
</configuration>
As this process takes a very long time greater than 10 minutes, so I found that I need to overwrite this value with a higher one.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With