"Odp.net Date" is in use with Oracle ODP. NET prompts ORA-00932 and ORA-01843 when performing an update

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.