title: VB.NET - Transaction rollback
body: <p>What happens if a transaction is neither committed nor rolled back.  I am looking for answers for SQL Server and/or Oracle.  Please see the code below:</p>
  
  <pre><code>Public Sub TransactionTest()
          Try
              Dim intCount As Integer
              Dim sql As SqlTransaction
              Dim objCon As New SqlConnection("Data Source=IANSCOMPUTER;Initial Catalog=Test;Integrated Security=True;MultipleActiveResultSets=true")
              objCon.Open()
              Dim trans As SqlTransaction
              trans = objCon.BeginTransaction
              Dim paramValues(0) As SqlParameter
              paramValues(0) = New SqlParameter("@ID", 1)
              Using (objCon)
                  intCount = SqlHelper.ExecuteNonQuery(trans, CommandType.Text, "UPDATE person SET URN=1 WHERE ID2=@ID", paramValues)
                  paramValues(0) = New SqlParameter("@ID", 2)
                  intCount = SqlHelper.ExecuteNonQuery(trans, CommandType.Text, "UPDATE person SET URN=2 WHERE ID2=@ID", paramValues)
                  paramValues(0) = New SqlParameter("@ID", 3)
                  intCount = SqlHelper.ExecuteNonQuery(trans, CommandType.Text, "UPDATE person SET URN=3 WHERE ID2=@ID", paramValues)
              End Using
          Catch ex As Exception
              'I do not swallow transactions
          End Try
      End Sub
  </code></pre>
  
  <p>Notice that it is neither committed nor rolled back.  In the case above it appears to roll back.</p>
  
  <p>I have noticed that on my SQL Server 2005 Express server at home that SQL Studio Manager hangs when running a query directly in the console until the program above finishes.  In my work environment this is not the case i.e. you can run queries simultaneously.  Is this because of the isolation level? Therefore I have two questions:</p>
  
  <ol>
  <li>What happens if a transaction is neither committed nor rolled back.  I have read articles like this: <a href="https://stackoverflow.com/questions/4896479/what-happens-if-you-dont-commit-transaction-in-a-database-say-sql-server">What happens if you don&#39;t commit transaction in a database (say SQL Server)</a>.  Can I assume that the transaction is rolled back in SQL Server and Oracle?</li>
  <li>Why does SQL server hang in one environment when a transaction is active and in another environment it does not?</li>
  </ol>
  
  <p>I am looking specifically for an anwer to question 2.</p>