尝试调用过程并传递参数获取错误

时间:2018-11-02 04:32:30

标签: c# asp.net oracle ado.net

我正在尝试调用存储过程并传递参数,但是出现错误

  

内部.net框架数据提供程序错误30

在此代码行上:

conn.CallProcedure("DBPRD.insertUnit(P_ID=:COLUMN1,REV=:COLUMN2,'804',PROP=:COLUMN3,CRTDBY=:COLUMN4)", P_ID,REV,PROP,CRTD_BY);

我的完整代码:

public int CallProcedure(string cmdText, params object[] param)
{
        int rowsAffected = 0;

        using (OracleConnection connection = new OracleConnection(connectionString))
        {
            OracleCommand command = new OracleCommand(cmdText, connection);
            OracleTransaction insTransaction;

            connection.Open();

            insTransaction = connection.BeginTransaction();
            command.CommandType = CommandType.StoredProcedure;
            command.Transaction = insTransaction;

            for (int i = 0; i < param.Length; i++)
            {
                command.Parameters.AddWithValue(":COLUMN" + (i + 1).ToString(), param[i]);
            }

            try
            {
                rowsAffected = command.ExecuteNonQuery();
                insTransaction.Commit();
            }
            catch (Exception ex)
            {
                insTransaction.Rollback();
            }
            finally
            {
                command.Dispose();
                connection.Close();
            }
        }

        return rowsAffected;
    }

任何解决此问题的想法都会受到赞赏。

0 个答案:

没有答案