title: Updating Oracle Table using Stored Procedure from C# Odd bug
body: <p>I am using a stored procedure to Insert a new user or update their existing information if the user already exists in the Database.</p>
  
  <p>I am grabbing 3 of the Parameters (User name, first name, and last name) from Active Directory and using 4 textboxes to grab the rest (PI Code, phone, email, address). </p>
  
  <pre><code>&lt;asp:TextBox ID="TXT_PI_CODE" runat="server" style="position: absolute; left:120px; top:100px;"&gt;&lt;/asp:TextBox&gt;
  &lt;asp:RequiredFieldValidator ID="RequiredFieldValidator_PI_CODE" runat="server" ErrorMessage="" ControlToValidate="TXT_PI_CODE"&gt;&lt;/asp:RequiredFieldValidator&gt;
  &lt;br /&gt;
  &lt;asp:TextBox ID="TXT_EMAIL" runat="server" style="position: absolute; left:120px; top:140px;"&gt;&lt;/asp:TextBox&gt;
  &lt;asp:RequiredFieldValidator ID="RequiredFieldValidator_EMAIL" runat="server" ErrorMessage="" ControlToValidate="TXT_EMAIL"&gt;&lt;/asp:RequiredFieldValidator&gt;
  &lt;asp:RegularExpressionValidator ID="RegularExpressionValidator_EMAIL" runat="server" ErrorMessage="Invalid Email Format." ControlToValidate="TXT_EMAIL" style="position: absolute; top:140px; left:300px;" ValidationExpression="[a-z0-9!#$%&amp;'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&amp;'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?"&gt;&lt;/asp:RegularExpressionValidator&gt;
  &lt;br /&gt;
  &lt;asp:TextBox ID="TXT_PHONE" runat="server" style="position: absolute; left:120px; top:180px;"&gt;&lt;/asp:TextBox&gt;
  &lt;asp:RequiredFieldValidator ID="RequiredFieldValidator_PHONE" runat="server" ErrorMessage="" ControlToValidate="TXT_PHONE"&gt;&lt;/asp:RequiredFieldValidator&gt;
  &lt;br /&gt;
  &lt;asp:TextBox ID="TXT_ADDRESS" runat="server" style="position: absolute; left:120px; top:220px;" Width="200"&gt;&lt;/asp:TextBox&gt;
  &lt;asp:RequiredFieldValidator ID="RequiredFieldValidator_ADDRESS" runat="server" ErrorMessage="" ControlToValidate="TXT_ADDRESS"&gt;&lt;/asp:RequiredFieldValidator&gt;
  &lt;br /&gt;
  &lt;asp:Label ID="LBL_REQUIRED" runat="server" Text="*Required Fields" CssClass="labels" style="position: absolute; top:260px;" ForeColor="#FF9900"&gt;&lt;/asp:Label&gt;
  &lt;asp:Button ID="BTN_SUBMIT" runat="server" Text="Submit" 
      style="position: absolute; top:300px; left:120px;" Width="100" Height="40" 
      OnClick="BTN_SUBMIT_Click"/&gt;
  </code></pre>
  
  <p>My Stored Procedure is as follows:</p>
  
  <pre><code>create or replace
  PROCEDURE SP_ADD_USER
  (
    p_USER_NAME IN T_USER.USER_NAME%TYPE,
    p_FIRST_NAME IN T_USER.FIRST_NAME%TYPE,
    p_LAST_NAME IN T_USER.LAST_NAME%TYPE,
    p_PI_CODE IN T_USER.PI_CODE%TYPE,
    p_EMAIL IN T_USER.EMAIL%TYPE,
    p_PHONE IN T_USER.PHONE%TYPE,
    p_ADDRESS IN T_USER.ADDRESS%TYPE
  )
  AS
  BEGIN
    INSERT INTO T_USER (USER_ID, USER_NAME, FIRST_NAME, LAST_NAME, PI_CODE, EMAIL, PHONE, ADDRESS) 
    VALUES (S_USER.NEXTVAL, p_USER_NAME, p_FIRST_NAME, p_LAST_NAME, p_PI_CODE, p_EMAIL, p_PHONE, p_ADDRESS);
  EXCEPTION   
  WHEN DUP_VAL_ON_INDEX THEN
  UPDATE T_USER
  SET    
  PI_CODE = p_PI_CODE,
  EMAIL = p_EMAIL,
  PHONE = p_PHONE,
  ADDRESS = p_ADDRESS
  WHERE LOWER(USER_NAME) = p_USER_NAME;
  COMMIT;
  END;
  </code></pre>
  
  <p>And finally my C# looks like this:</p>
  
  <pre><code>protected void BTN_SUBMIT_Click(object sender, EventArgs e)
  {
      //Retrieve Username, firstname, and last name from AD.
      string STR_USER_ID = ADQuery.ExtractUserName(User.Identity.Name.ToString());
      string STR_FIRST_NAME = ADQuery.GetADValue(STR_USER_ID, "givenName");
      string STR_LAST_NAME = ADQuery.GetADValue(STR_USER_ID, "SN");
  
      string connectionString = WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
  
      using(OracleConnection connection = new OracleConnection(connectionString))
      {
          connection.Open();
  
          OracleCommand ora_cmd = new OracleCommand("SP_ADD_USER", connection);
          ora_cmd.BindByName = true;
          ora_cmd.CommandType = CommandType.StoredProcedure;
  
          ora_cmd.Parameters.Add("p_USER_NAME", OracleDbType.Varchar2, STR_USER_ID.ToLower(), ParameterDirection.Input);
          ora_cmd.Parameters.Add("p_FIRST_NAME", OracleDbType.Varchar2, STR_FIRST_NAME, ParameterDirection.Input);
          ora_cmd.Parameters.Add("p_LAST_NAME", OracleDbType.Varchar2, STR_LAST_NAME, ParameterDirection.Input);
          ora_cmd.Parameters.Add("p_PI_CODE", OracleDbType.Varchar2, TXT_PI_CODE.Text, ParameterDirection.Input);
          ora_cmd.Parameters.Add("p_EMAIL", OracleDbType.Varchar2, TXT_EMAIL.Text, ParameterDirection.Input);
          ora_cmd.Parameters.Add("p_PHONE", OracleDbType.Varchar2, TXT_PHONE.Text, ParameterDirection.Input);
          ora_cmd.Parameters.Add("p_ADDRESS", OracleDbType.Varchar2, TXT_ADDRESS.Text, ParameterDirection.Input);
  
          ora_cmd.ExecuteNonQuery();
      }
      Response.Redirect("Default.aspx");
  }
  </code></pre>
  
  <p>The insert portion works fine as a new user, however when attempting to update the information in the same text boxes nothing has updated on the database after the postback. However the oddity is that if I change my C# to </p>
  
  <pre><code> ora_cmd.Parameters.Add("p_PI_CODE", OracleDbType.Varchar2, TXT_EMAIL.Text, ParameterDirection.Input);
   ora_cmd.Parameters.Add("p_EMAIL", OracleDbType.Varchar2, TXT_EMAIL.Text, ParameterDirection.Input);
  </code></pre>
  
  <p>where both of those parameters are populated from the same textbox it will update the <code>PI_CODE</code> field on the database with what was originally in the email address textbox, but the email address will remain unchanged on the database.
  I don't know if there is some bug I am missing or my syntax is off? I've made sure my parameter orders are correct, or what I believe is correct. Anyone seen this before?</p>