Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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();
like image 568
Rohan21 Avatar asked Jul 06 '26 21:07

Rohan21


1 Answers

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.

like image 127
Habib Avatar answered Jul 08 '26 12:07

Habib



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!