C # update Oracle with parametric notation

Source: Internet
Author: User

Just transferred from the Mysql/mssql database to Oracle, the update was unsuccessful when called in C #, and was later found to be a problem with incorrect format of the pass parameter.

The command in Oracle is preceded by a colon: callout in front of the parameter name. Both SQL Server and MySQL use @. See Http://www.codeproject.com/Questions/618582/ORA-00936-missing-expression
 Public Static BOOLupdatenew (Entity.pw_user newuser) {Try{entity.pw_user TT=NewUser; StringBuilder SB=NewStringBuilder (); Sb. Append ("Update Pw_user Set"); Sb. Append ("Username=:username,"); Sb. Append ("password=:P Assword,"); Sb. Append ("Usergroupcode=:usergroupcode,"); Sb. Append ("Createtime=:createtime,"); Sb. Append ("Lastlogintime=:lastlogintime"); Sb. Append ("where Userid=:userid"); //the command in Oracle is preceded by a colon: callout in front of the parameter name.                Both SQL Server and MySQL use @. //See-----http://www.codeproject.com/Questions/618582/ORA-00936-missing-expressionOracleCommand cmd =NewOracleCommand (); Cmd.commandtext=sb.                ToString (); Cmd.commandtype=CommandType.Text; //The order of the following parameters must be the same as the order in which the arguments appear in the above statement.                Otherwise, the update is unsuccessful. //the following userid parameter cannot appear before any one of the previous 5 parameters. Cmd. Parameters.Add (NewOracleParameter ("UserName", ORACLEDBTYPE.NVARCHAR2, $) {Value =TT.                UserName}); Cmd. Parameters.Add (NewOracleParameter ("Password", ORACLEDBTYPE.VARCHAR2, $) {Value =TT.                Password}); Cmd. Parameters.Add (NewOracleParameter ("Usergroupcode", ORACLEDBTYPE.VARCHAR2, $) {Value =TT.                Usergroupcode}); Cmd. Parameters.Add (NewOracleParameter ("Createtime", ORACLEDBTYPE.VARCHAR2, $) {Value =TT.                Createtime}); Cmd. Parameters.Add (NewOracleParameter ("Lastlogintime", ORACLEDBTYPE.VARCHAR2, $) {Value =TT.                Lastlogintime}); Cmd. Parameters.Add (NewOracleParameter ("UserID", ORACLEDBTYPE.VARCHAR2, -) {Value =TT.                UserID}); intval =dbhelper_oracle.                ExecuteNonQuery (CMD); if(Val >0)                {                    return true; }                Else                {                    return false; }            }            Catch            {                return false; }        }

Hope to be useful to everyone.

C # update Oracle with parametric notation

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.