ORA 00936缺少表达式错误

时间:2018-03-18 10:52:21

标签: c#

 protected void Button1_Click1(object sender, EventArgs e)
    {
        using (OracleConnection conn = new OracleConnection())
        {
            conn.ConnectionString = connectionstring;
            conn.Open();
            OracleCommand cmd = new OracleCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Insert into PFC.Trial(FAME)VALUES(@FAME)";
            cmd.Parameters.Add(new OracleParameter("@FAME", TextBox1.Text));
            cmd.ExecuteNonQuery();     
        }
    }
    }
}

错误在这里 错误在最后一行
cmd.executenonquery();

1 个答案:

答案 0 :(得分:1)

您需要在设置参数时删除符号,也应该是冒号而不是@ for Oracle:

using (OracleConnection conn = new OracleConnection())
{
        conn.ConnectionString = connectionstring;
        conn.Open();
        OracleCommand cmd = new OracleCommand();
        cmd.Connection = conn;
        cmd.CommandText = "Insert into PFC.Trial(FAME)VALUES(:FAME)";
        cmd.Parameters.Add(new OracleParameter("FAME", TextBox1.Text));
        cmd.ExecuteNonQuery();     
}