title: How to use DataAdapter with SqlTransaction in C#?
body: <p>I need to create 2 buttons, one for starting a transaction (<code>startButton</code>) and one for committing a transaction (<code>commitButton</code>).</p>
  
  <p>I got stuck trying to implement it for the <code>SELECT</code> command.</p>
  
  <p>When I press the <code>commitButton</code> I get the error that the transaction has already completed and is no longer usable.</p>
  
  <pre><code>public void startTransaction(IsolationLevel isolationLevel) {
      connectSQL();
      connection.Open();
      transaction = connection.BeginTransaction(isolationLevel);
      Console.WriteLine("Transaction started !");
  }
  
  public void commitTransaction() {
      this.transaction.Commit();
      connection.Close();
      Console.WriteLine("Transaction commited !");
  }
  
  public DataTable readAllRezervari() {
      try {
          String selectSql = "SELECT * FROM Rezervari;";
          SqlCommand sqlCommand = new SqlCommand(selectSql, connection, transaction);
          rezervariDataAdapter.SelectCommand = sqlCommand;
          rezervariDataAdapter.Fill(rezervariDataSet, "Rezervari");
      }
      catch (Exception e) {
          Console.WriteLine("ERROR: " + e);
          try {
              transaction.Rollback();
          }
          catch (Exception e2) {
              Console.WriteLine("ERROR: " + e2);
          }
      }
      finally {
          connection.Close();
      }
      rezervariDataTable = rezervariDataSet.Tables["Rezervari"];
      return rezervariDataTable;
  }
  </code></pre>