0

每当我尝试从 C# 执行它时,我都会不断收到此存储过程错误(参数的数量或类型错误)。

这是 sproc 的变量定义:

requestNumber varchar2,
requestXML clob,
userID varchar2,
activityID integer,
origin_zip varchar2,
destination_zip varchar2,
pur_date varchar2

这是 C# 代码中 oracle 参数的定义:

OracleParameter _requestNumber = new OracleParameter("requestNumber", OracleDbType.Varchar2) { Direction = ParameterDirection.Input, Value = requestNumber };

OracleParameter _requestXML = new OracleParameter("requestXML", OracleDbType.Clob) { Direction = ParameterDirection.Input, Value = xml };

OracleParameter _userID = new OracleParameter("userID", OracleDbType.Varchar2) { Direction = ParameterDirection.Input, Value = input.UserID };

OracleParameter _activityID = new OracleParameter("activityID", OracleDbType.Int32) { Direction = ParameterDirection.Input, Value = Convert.ToInt32(activityID) };

OracleParameter _sOriginZip = new OracleParameter("origin_zip", OracleDbType.Varchar2) { Direction = ParameterDirection.Input, Value = _originZip };

OracleParameter _sDestinationZip = new OracleParameter("destination_zip", OracleDbType.Varchar2) { Direction = ParameterDirection.Input, Value = _destinationZIP };

OracleParameter _sPurDate = new OracleParameter("pur_date", OracleDbType.Varchar2) { Direction = ParameterDirection.Input, Value = _purDate };

                command.Parameters.Add(_requestNumber);
                command.Parameters.Add(_requestXML);
                command.Parameters.Add(_userID );
                command.Parameters.Add(_activityID );
                command.Parameters.Add( _sOriginZip);
                command.Parameters.Add( _sDestinationZip);
                command.Parameters.Add( _sPurDate);

什么可能导致该异常?

4

1 回答 1

0

在添加参数之前尝试使用以下代码清除命令参数,

command.Parameters.Clear();

还要检查你是否设置command.Type为 storedProcedure

于 2012-06-18T14:06:16.610 回答