title: Committing a transaction while inside a datareader loop
body: <p>I'm looping inside a reader and updating a different table the reader is reading from. Every 1000 loops I want to commit() the transation but it's giving the error:</p>
  
  <blockquote>
    <p>The transaction operation cannot be performed because there are
    pending requests working on this transaction.</p>
  </blockquote>
  
  <p>I've seen 2 other answers and one of them said close the reader but we obviously can't do that as we're using that data from the reader to run an update statement and update another table.</p>
  
  <p>So the question is, if you create a transaction on a connection, then you have a datareader looping over some sql command, how can I, within the datareader loop, run an update command and commit() the transaction inside the datareader loop?</p>