It should work but it doesn’t.
I have referred others but couldn’t find the reason.
OracleCommand cmd = con.CreateCommand(); var query = $@"UPDATE Customer SET ContactName = :ct WHERE CustomerID = :id"; cmd.CommandText = query; cmd.Parameters.Clear(); cmd.Parameters.Add(new OracleParameter(":id", OracleDbType.Varchar2, "bbb1", System.Data.ParameterDirection.Input)); cmd.Parameters.Add(new OracleParameter(":ct", OracleDbType.Varchar2, "Joon", System.Data.ParameterDirection.Input)); var rst = cmd.ExecuteNonQuery();
Thanks in advance.
Joon
Advertisement
Answer
I found why it didn’t update table.
To make it work I added parameters in the order of the query parameter and found it works. But I still do not understand why the order of adding parameters is so important to make it work.But the thing clear is that it is working when I make it like this:
OracleCommand cmd = con.CreateCommand(); var query = $@"UPDATE Customer SET ContactName = :ct WHERE CustomerID = :id"; cmd.CommandText = query; cmd.Parameters.Clear(); cmd.Parameters.Add(new OracleParameter(":ct", OracleDbType.Varchar2, "Joon", System.Data.ParameterDirection.Input)); cmd.Parameters.Add(new OracleParameter(":id", OracleDbType.Varchar2, "bbb1", System.Data.ParameterDirection.Input)); var rst = cmd.ExecuteNonQuery();
Thanks everybody who paid attention on it.
Joon