Problem
The underlying database link is modified by oracle.client to the Odp.net connection database to improve execution efficiency.
The following issues were found when executing the statement
Cmd.commandtext = "Update sys_user set Lastlogin=:lastlogin, mobilephone= ' 13000000000 ' where userid=:userid11";
First prompt ORA-01843 Invalid month, found odp.net use oracledbtype.date, dbparameter.value need for System.DateTime type
Continue to prompt ORA-00932 "ORA-00932: data type inconsistency: should be Number , But it gets the DATE "
Check that the data type is exactly the same.
Analysis
Re-write code debugging as follows
OracleCommand cmd = conn. CreateCommand (); cmd. CommandText = "Update Sys_user set lastlogin=:lastlogin, mobilephone= ' 13000000000 ' where userid=: USERID11 "; OracleParameter P1 = new OracleParameter ("Lastlogin", Oracledbtype.date);p 1. Value = Convert.todatetime (DateTime.Now.ToString ()); Cmd. Parameters.Add (p1); OracleParameter P2 = new OracleParameter ("USERID11", Oracledbtype.int32);p 2. Value = Int. Parse ("1"); Cmd. Parameters.Add (p2); int i = cmd. ExecuteNonQuery ();
Successful execution
oraclecommand cmd = conn. CreateCommand (); cmd. CommandText = "Update sys_user set Lastlogin=:lastlogin, mobilephone= ' 13000000000 ' where userid=:userid11"; OracleParameter P2 = new OracleParameter ("USERID11", Oracledbtype.int32);p 2. Value = Int. Parse ("1"); Cmd. Parameters.Add (p2); int i = cmd. ExecuteNonQuery (); OracleParameter P1 = new OracleParameter ("Lastlogin", Oracledbtype.date);p 1. Value = Convert.todatetime (DateTime.Now.ToString ()); Cmd. Parameters.Add (p1);
Execution failed with error:ORA-00932: data type inconsistent: number expected , but it gets the DATE "
Conclusion
By searching, it is found that Odp.net's OracleCommand default has a property Bindbyname is false, and oracle.client default is not the same.
Need to enable OracleCommand Bindbyname by default
"Odp.net Date" is in use with Oracle ODP. NET prompts ORA-00932 and ORA-01843 when performing an update