Skip to Main Content



For appeals, questions and feedback, please email

c# parameter order matters, why

Markus RissmannDec 6 2023 — edited Dec 7 2023

c#, .Net 8, ManagedDatqaAccess.Core 3.21.120

(I have basically erased the original post and have replaced it since I found the issue)

Apparently, the order in which you add parameters matters but I would think it should not.

The following fails

string sSQL =
    "UPDATE hours SET " +
    " MODIFY_DATE = :p1" +
    " WHERE KEY = :p2 ";

using var oComm = new OracleCommand(sSQL, conn);
oComm.CommandType = CommandType.Text;

oComm.Parameters.Add("p2", 99999);
oComm.Parameters.Add("p1", DateTime.Now);

await oComm.ExecuteNonQueryAsync();

if I switch around:

oComm.Parameters.Add("p1", DateTime.Now);
oComm.Parameters.Add("p2", 99999);

It works. I would assume that it would be looking up the parameter by name, but it does not appear to be doing that.

Even if I fill the parameter definition fully, it doesn't work:

oComm.Parameters.Add("p2", OracleDbType.Int32, 99999, ParameterDirection.Input);


This post has been answered by Alex Keh-Oracle on Dec 7 2023
Jump to Answer
Post Details
Added on Dec 6 2023