无法更新Oracle数据库的数字类型列

时间:2019-06-13 05:53:48

标签: c# database oracle

我正在尝试使用C#中的以下代码更新Oracle数据库中的Number(19,2)类型的列。但是,它不会更新表中的数据。金额-数据库中的类型为Number(19,2),我尝试用十进制,Int64,Long替换Varchar2,但仍然没有运气。并且request.amount是float类型。

任何提示将不胜感激。谢谢

try
{

  OracleCommand command2 = new OracleCommand();

  command2.CommandText = "Update t_payment set amount = :amount where penalty_order_id = (select id from t_penalty_order where protokol_no = :invoiceNumber)";


  command2.Parameters.Add(new OracleParameter(@"invoiceNumber", OracleDbType.Varchar2, 255)).Value = request.invoiceNumber;
  command2.Parameters.Add(new OracleParameter(@"amount", OracleDbType.Varchar2, 255)).Value = request.amount; //(Convert.ToInt32 (request.amount) + paid_amount);
  command2.Connection = connection;

  command2.CommandType = System.Data.CommandType.Text;


  command2.ExecuteNonQuery();


}
catch (Exception e)
{
  completePayment.code = 111;
  completePayment.message = e.Message;
  completePayment.transactionNumber = null;
}

1 个答案:

答案 0 :(得分:0)

我发现了问题。这是按添加参数的顺序进行的。我必须先添加数量参数值,然后再添加protokol_no。