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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With