title: How to use OracleConnection with different queries C#
body: <p>I can't understand how to work with OracleConnection object</p>
  
  <p>Use it for all queries? Or one connection for one query?</p>
  
  <p>My program do:</p>
  
  <p>1) Recieve data from Oracle DB (cursor) (~100.000 - 1.000.000 records)</p>
  
  <p>2) For each selected record (id) update value at another table</p>
  
  <p>What is correct:</p>
  
  <p>1) Create OracleConnection for each query</p>
  
  <pre><code>using(OracleConnection connection = new OracleConnection(connectionString))  
  {
      using(OracleCommand command = new OracleCommand(recieveSql, connection))
      {
          connection.Open();
          ...
          command.ExecuteNonQuery();
          ...
          using(OracleDataReader reader = command.ExecuteReader())
          {
              while(reader.Read())
              {
                  int id = reader.GetInt32(0);
                  string value = reader.GetInt32(1);
                  UpdateRecord(id, value);
              }
          }
      }
  }
  
  
  private void UpdateRecord(int id, string value)
  {
      using(OracleConnection connection = new OracleConnection(connectionString))  
      {
          using(OracleCommand command = new OracleCommand(updateSql, connection))
          {
              connection.Open();
              ...
              command.Parameters.AddWithValue("@id", id);
              command.Parameters.AddWithValue("@value", value);
              command.ExecuteNonQuery();
              ...
          }
      }
  }
  </code></pre>
  
  <p>2) Use 1 OracleConnection for all queries</p>
  
  <pre><code>using(OracleConnection connection = new OracleConnection(connectionString))  
  {
      using(OracleCommand command = new OracleCommand(recieveSql, connection))
      {
          connection.Open();
          ...
          command.ExecuteNonQuery();
          ...
          using(OracleDataReader reader = command.ExecuteReader())
          {
              while(reader.Read())
              {
                  int id = reader.GetInt32(0);
                  string value = reader.GetInt32(1);
                  UpdateRecord(connection, id, value);
              }
          }
      }
  }
  
  
  private void UpdateRecord(OracleConnection connection, int id, string value)
  {
      using(OracleCommand command = new OracleCommand(updateSql, connection))
      {
          ...
          command.Parameters.AddWithValue("@id", id);
          command.Parameters.AddWithValue("@value", value);
          command.ExecuteNonQuery();
          ...
      }
  }
  </code></pre>