title: TransactionScope giving error Distributed transaction completed. Either enlist this session in a new transaction or the NULL transaction
body: <p>I am writing a Class library in c# to perform Archiving functions for production database (using SQLServer 2000). In the function, I am moving records from production database to Archive database for multiple tables and using transactionScope to rollback the changes if something fails.</p>
  
  <p>Since large data is being moved from production database to Archive database, it is taking at least 1/2 hr. If I remove transactionScope, everything works fine but with transactionScope, I get below error after 9-10 minutes.</p>
  
  <p><strong>Distributed transaction completed. Either enlist this session in a new transaction or the NULL transaction.</strong> </p>
  
  <p>below is pseudo code </p>
  
  <pre><code>using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(2, 0, 0)))
  {
      Open connection
      Check data present in production DB
  
  Insert into Archivedb.dbo.table1(field1,field2,field3....) Select * from Proddb.dbo.table1 where date between date1 and date2
  Insert into Archivedb.dbo.table2(field1,field2,field3....) Select * from Proddb.dbo.table2 where date between date1 and date2
  Insert into Archivedb.dbo.table3(field1,field2,field3....) Select * from Proddb.dbo.table3 where date between date1 and date2
  Insert into Archivedb.dbo.table4(field1,field2,field3....) Select * from Proddb.dbo.table4 where date between date1 and date2
  }
  </code></pre>
  
  <p>Do I need to set timeout somewhere ?</p>
  
  <h2><strong>EDIT</strong></h2>
  
  <p>Found the solution in below link after breaking my head for so long
  <a href="http://blogs.msdn.com/b/dotnetinterop/archive/2005/12/16/504604.aspx" rel="nofollow">http://blogs.msdn.com/b/dotnetinterop/archive/2005/12/16/504604.aspx</a>
  Hope it will help others too.</p>