无法使用C#更新Oracle数据库中表的列

时间:2019-06-14 05:52:03

标签: c# oracle

我正在尝试更新Oracle数据库中的两个表。第一个try / catch部分工作正常,但是,尽管我使用了相同的代码,但第二个并没有更新刑罚列。该查询在Toad上运行良好。我试图通过合并sql查询将它们合并到一个try / catch中,但是在第二个表上却不起作用。

感谢您的帮助。

谢谢

try
{

    OracleCommand command2 = new OracleCommand();

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

    command2.Parameters.Add(new OracleParameter(@"amount", OracleDbType.Int32)).Value = Convert.ToInt32(request.amount);
    command2.Parameters.Add(new OracleParameter(@"invoiceNumber", OracleDbType.Varchar2, 255)).Value = request.invoiceNumber;

    command2.Connection = connection;

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


    command2.ExecuteNonQuery();


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




try
{

    OracleCommand command2 = new OracleCommand();

    command2.CommandText = "Update t_penalty_order set penalty_fine = 10 where protokol_no = :invoiceNumber";


    command2.Parameters.Add(new OracleParameter(@"invoiceNumber", OracleDbType.Varchar2, 255)).Value = request.invoiceNumber;

    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)

我重新启动了远程服务器,它开始工作。谢谢