C
Curious
I have the following C#.NET code that executes a stored procedure and
returns an integer value from the stored procedure:
//insert to algo_executions
IDbCommand command = mConn.CreateCommand();
command.CommandType = CommandType.StoredProcedure;
command.CommandText =
"db_dynamic_trading.dbo.algo_insert_run_info";
// Convert day to DateTime format
DateTime date = new DateTime();
date = Convert.ToDateTime(mFirstTradingDay);
command.Parameters.Add(new SqlParameter("@FirstDay",
date));
command.Parameters.Add(new SqlParameter("@LimitType",
mLimitType.ToString()));
command.Parameters.Add(new SqlParameter
("@ParticipationRate", mMarketPercent));
command.Parameters.Add(new SqlParameter
("@CashPercentage", mCashPercent));
SqlParameter returnValueParam = new SqlParameter
("@RunId", 0);
returnValueParam.Direction =
ParameterDirection.ReturnValue;
command.Parameters.Add(returnValueParam);
command.ExecuteNonQuery();
int returnValue = (int)returnValueParam.Value;
However, it throws an exception upon executing the line of code with
"ExecuteNonQuery". The error is
"Procedure or function 'algo_insert_run_info' expects parameter
'@RunId', which was not supplied." I think I have supplied this
parameter before "ExecuteNonQuery". Any suggestion on how to get this
fixed?
returns an integer value from the stored procedure:
//insert to algo_executions
IDbCommand command = mConn.CreateCommand();
command.CommandType = CommandType.StoredProcedure;
command.CommandText =
"db_dynamic_trading.dbo.algo_insert_run_info";
// Convert day to DateTime format
DateTime date = new DateTime();
date = Convert.ToDateTime(mFirstTradingDay);
command.Parameters.Add(new SqlParameter("@FirstDay",
date));
command.Parameters.Add(new SqlParameter("@LimitType",
mLimitType.ToString()));
command.Parameters.Add(new SqlParameter
("@ParticipationRate", mMarketPercent));
command.Parameters.Add(new SqlParameter
("@CashPercentage", mCashPercent));
SqlParameter returnValueParam = new SqlParameter
("@RunId", 0);
returnValueParam.Direction =
ParameterDirection.ReturnValue;
command.Parameters.Add(returnValueParam);
command.ExecuteNonQuery();
int returnValue = (int)returnValueParam.Value;
However, it throws an exception upon executing the line of code with
"ExecuteNonQuery". The error is
"Procedure or function 'algo_insert_run_info' expects parameter
'@RunId', which was not supplied." I think I have supplied this
parameter before "ExecuteNonQuery". Any suggestion on how to get this
fixed?