title: How to execute an update query?
body: <p>I know how I do this, I have actually done it before, but the following code HANGS (not throw an exception) in this update statement below, and I don't see a reason for it. Can anyone see why?</p>
  
  <p>I don't think is important but <code>id</code> is the primary key of <code>Person</code> and <code>belongs</code> is a foreign key.</p>
  
  <p>Before any sugest concurrence problem, I am the only person working on the tables.
  The creation of the command is so:</p>
  
  <pre><code>public static String upDatePersonBelonging(Int32 personId,Int32 groupId)
  {
      String error;
      if ((error = openConnection()) != "")
          return error;
  
      OracleCommand command = 
        new OracleCommand("UPDATE person SET belongs = :belongs where id = :id ",
                           connection);
  
      addParameter(command, "belongs", OracleDbType.Int32, groupId);
      addParameter(command, "id", OracleDbType.Int32, personId);
  
      return runCommand(command);
  }
  </code></pre>
  
  <p>The execution is so:</p>
  
  <pre><code>private static String runCommand(OracleCommand command)
  {
      String error = "";
  
      try
      {
          command.ExecuteNonQuery(); // here it hangs
      }
      catch (Exception e)
      {
          error = e.Message;
      }
      finally
      {
          connection.Close();
      }
  
      return error;
  }
  </code></pre>
  
  <p>The opening function is the following:</p>
  
  <pre><code>private static String openConnection()
  {
      try
      {
          // create an open the connection          
          connection = new OracleConnection(_connStr);
  
          // open the connection
          connection.Open();
      }
      catch(Exception e)
      {
          return e.Message;
      }
  
      return "";
  }
  </code></pre>
  
  <p>add parameter code:</p>
  
  <pre><code>private static void addParameter(OracleCommand command, String name, OracleDbType type, Object value)
  {
      command.Parameters.Add(name, type);
      command.Parameters[command.Parameters.Count-1] = new OracleParameter(name, value);
  }
  </code></pre>