【问题标题】:ORA-00936 missing expressionORA-00936 缺少表达式
【发布时间】:2014-03-27 17:00:50
【问题描述】:

当用户投票时,我需要更新我的表格列 votecount,但我遇到了这个错误,我不知道如何处理它。

 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();

【问题讨论】:

    标签: c# oracle


    【解决方案1】:

    您需要将参数@Prsdent 更改为:Prsdent

    见:OracleCommand.Parameters Property

    在 SQL 语句中使用命名参数时 CommandType.Text 的 OracleCommand,必须在参数之前 带有冒号 (:) 的名称。

    还可以考虑将您的命令和连接对象包含在using statement 中,因为这样可以确保正确处理资源。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-18
      • 2017-08-31
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多