title: The CommandText property has not been properly initialized error when Transactionalized
body: <p>This code had previously been working fine. I need to transactionalize my read writes however, and when trying to begin that process by transactionalizing my read, I've ran into this commandText uninitialized error. </p>
  
  <p>Exact Error, Line 156 is  <code>DA.Fill(tbl);</code></p>
  
  <pre><code>Error: System.InvalidOperationException: The CommandText property has not been properly initialized.
     at MySql.Data.MySqlClient.ExceptionInterceptor.Throw(Exception exception)
     at MySql.Data.MySqlClient.MySqlConnection.Throw(Exception ex)
     at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
     at MySql.Data.MySqlClient.MySqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
     at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)
     at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
     at System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior)
     at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)
     at MDB_N2000.DatabaseManager.GetTable(TableQuery query) in C:\Users\Tcordeau.pub\DocumentsException thrown: 'System.InvalidOperationException' in MySql.Data.dll
  \MDB-N2000\MDB-N2000\Model\DatabaseManager.cs:line 156 The CommandText property has not been properly initialized.
  </code></pre>
  
  <ol>
  <li><p>Call LoadTable. </p>
  
  <pre><code>public void LoadTable()
  {
      if (Db.IsConnOpen)
      {
          Db.BeginTransaction();
          // Persist the selected row across table reload by keeping track of the row's first value.
          // For this to work, tables need to always have an autonumbered integer index in the first column.
          // Store the row index.
          if (Vals.Any())
              if (Vals[0].Val != null)
                  if (Vals[0].Val.GetType() == typeof(int))
                      RowID = Vals[0].Val;
  
          // For tables in the sub-tables viewer, get the key value of the main table of the module
          // to use as a parameter in the SQL select query.
          if (!IsMainTable)
          {
              LoadTableQuery.Prms[0].Val = MainVM.Modules.SelectedModule.Vwr.Table.Vals[0].Val;
          }
  
          // Get the table from the database
          Tbl = Db.GetTable(LoadTableQuery);
          DataTable MainTable = Db.GetTable(LoadTableQuery);
          MainTable.TableName = "MainTable";
          dv.Table = MainTable;
  
          // Retrieve the row index and set the selected row.
          if (Vals.Any())
              if (Vals[0].Val != null)
                  if (Vals[0].Val.GetType() == typeof(int))
                      Tbl.DefaultView.Sort = Tbl.Columns[0].ColumnName.ToString();
          //SelectedRowIndex = Tbl.DefaultView.Find(RowID);
          Db.CommitTransaction();
      }
  }
  </code></pre></li>
  <li><p>goes to GetTable.</p>
  
  <pre><code>public DataTable GetTable(TableQuery query)
  {
      DataTable tbl = new DataTable();
      if (IsConnOpen)
      {
          try
          {
              SelectCmd.Parameters.Clear();
              SelectCmd.CommandText = query.Qry;
              for (int i = 0; i &lt; query.Prms.Count; i++)
              {
                  SelectCmd.Parameters.AddWithValue(query.Prms[i].Col, query.Prms[i].Val);
              }
              // DA = MySQLDataAdapter
              DA.Fill(tbl);
              tbl.DefaultView.Sort = tbl.Columns[0].ColumnName.ToString() + " ASC";
  
          }
          catch (MySqlException ex)
          {
              Msg = "Error: " + ex.Number + " " + ex.Message + " from Qry = " + query.Qry;
          }
          catch (Exception ex)
          {
              Msg = "Error: " + ex + " " + ex.Message;
          }
      }
      else
      {
          Msg = "Not Connected";
      }
      return tbl;
  }
  </code></pre></li>
  </ol>
  
  <p>I've printed the query to console before to make sure it's not blank.</p>
  
  <p><strong>reference methods.</strong> </p>
  
  <pre><code>    private DatabaseManager()
      {
          Acct = new Account();
  
          SelectCmd = new MySqlCommand() { Connection = Conn };
          UpdateCmd = new MySqlCommand() { Connection = Conn };
          Cmd = new MySqlCommand() { Connection = Conn };
          DA = new MySqlDataAdapter(SelectCmd)
          {
              UpdateCommand = UpdateCmd
          };
  
          Msg = "Ready to Connect";
      }
  
      // Creates a new transaction and returns the command it's attached to.
      public void BeginTransaction()
      {
          SelectCmd = Conn.CreateCommand();
          MySqlTransaction NewTransaction = Conn.BeginTransaction();
          SelectCmd.Connection = Conn;
          SelectCmd.Transaction = NewTransaction;
      }
  
      //rollsback transaction
      public void RevertTransaction()
      {
          Cmd.Transaction.Rollback();
      }
  
      //adds a query to the transaction
      public void TransactionQuery(TableQuery NewQuery)
      {
          Cmd.CommandText = NewQuery.Qry;
          Cmd.ExecuteNonQuery();
      }
  
      //commits transaction
      public void CommitTransaction()
      {
          SelectCmd.Transaction.Commit();
      }
  </code></pre>