简体   繁体   中英

ORA-00936 missing expression

i need to update my table column votecount when a user voted but im having this error and i dont know what to do with it.

 private void Vote(string VoteId)
    {

        OracleCommand cmd = new OracleCommand("UPDATE ADMIN.CANDIDATES SET VOTE_COUNT=(VOTE_COUNT+1) WHERE PRSDENT=@Prsdent");
        con.Open();
        cmd.CommandType = CommandType.Text;
        cmd.Connection = con;
        cmd.Parameters.Add("@Prsdent", VoteId);
        cmd.ExecuteNonQuery();
        con.Close();

You need to change your parameter @Prsdent to :Prsdent

See: OracleCommand.Parameters Property

When using named parameters in an SQL statement called by an OracleCommand of CommandType.Text, you must precede the parameter name with a colon (:).

Also consider enclosing your command and connection object in using statement as that will ensure proper disposal of resources.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM