I finally figured it out.
It turns out that Oracle's default behavior is to bind the parameters in the order they were defined in the query.
So to make my sample program work, I have two solutions.
1 - Switch the order of parameter binding
Change
command.CommandType = CommandType.Text;
command.CommandText = "UPDATE Enterprise SET Name = :Name WHERE Id = :Id";
command.Parameters.Add(":Name", "toto");
command.Parameters.Add(":Id", id.ToString("N").ToUpper());
To
command.CommandType = CommandType.Text;
command.CommandText = "UPDATE Enterprise SET Name = :Name WHERE Id = :Id";
command.Parameters.Add(":Id", id.ToString("N").ToUpper());
command.Parameters.Add(":Name", "toto");
2 - Use BindByName
Set the BindByName
property to true
.
command.CommandType = CommandType.Text;
command.BindByName = true;
command.CommandText = "UPDATE Enterprise SET Name = :Name WHERE Id = :Id";
command.Parameters.Add(":Id", id.ToString("N").ToUpper());
command.Parameters.Add(":Name", "toto");