Skip to Main Content

ODP.NET

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

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);

-Markus

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