title: SSIS - Sql transaction rollback throwing error
body: <p>I have created an SSIS 2012 package with a <em>for loop container</em> planned to run continuously (infinite loop) so that it can process an incoming Excel file as soon as it is dropped into a designated drop directory. The processing involves first clearing all the existing records in the target SQL Server 2012 database table and then bulk inserting the data from the Excel into the table. So obviously it needs to maintain transaction, so that the data deletion operation can be rolled back in case the bulk insert fails (due to invalid file data, etc). </p>
  
  <p>Below are the tasks in the for loop container :</p>
  
  <ol>
  <li><p><strong>Script Task</strong> which leverages the C# <em>FileSystemWatcher</em> to watch for an Excel file dropped to the drop folder. </p></li>
  <li><p><strong>Execute SQL Task</strong> with the below statement :</p></li>
  </ol>
  
  <blockquote>
    <p>Begin Transaction tran1;</p>
  </blockquote>
  
  <ol start="3">
  <li><p><strong>Data Flow Task</strong> with Excel Source and OLEDB destination to insert the data from Excel to the SQL Server database table. This task has an OnError error handler which uses an Execute SQL Task to log the error details to a user defined error log table. </p></li>
  <li><p>On success precedence constraint of the above, an <strong>Execute SQL Task</strong> with the below statement :</p></li>
  </ol>
  
  <blockquote>
    <p>Commit Transaction tran1;</p>
  </blockquote>
  
  <ol start="5">
  <li>On failure precedence constraint of #3 above, an <strong>Execute SQL Task</strong> with the below statement :</li>
  </ol>
  
  <blockquote>
    <p>Rollback Transaction tran1;</p>
  </blockquote>
  
  <p>Note that I cannot use the default DTC based transaction as MSDTC is not enabled in the database server. Hence using the native SQL transaction. Also, I am using a single OLEDB connection manager in all DB related tasks (it is a remote Sql Server database, hence using OLE DB). The <strong>RetainSameConnection</strong> property of the Oledb Connection Manager is set to True. Also, all DB related tasks have their transaction option set to <strong>Supported</strong>. 
  However, on running the package with an incoming Excel file with invalid data, the task #5 for rollback throws following error and the same is logged into the error log table :</p>
  
  <p><em>The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION</em></p>
  
  <p>I should add that, for a valid Excel file, the package runs fine with the Commit Transaction (task #4) completing without error. 
  Any idea what might cause the transaction rollback to throw the error? </p>