每当我尝试从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);
可能导致该异常的原因是什么?
答案 0 :(得分:0)
在添加参数之前,使用以下代码尝试清除命令参数
command.Parameters.Clear();
同时检查您是否设置了command.Type
到storedProcedure