0
我有什么似乎是一个常见问题,但没有任何明显的错误。过程或函数期望没有提供参数 - 但参数WAS提供
我已经看过所有相关的主题,我可以看到与我的问题没有任何相似之处,因为我没有犯任何“明显的”错误,至少与其他人不相似。
我的存储过程声明:
CREATE PROCEDURE [dbo].[sp_AddEventTemp]
@iUserID int,
@iVerb int,
@iObject int,
@iResult int,
@nTransactionID numeric Output
,代码:
var userId = 9530;
var verb = 2;
var objectId = 15;
var transactionId = 0;
using (var connection = new SqlConnection(ConnectionString()))
{
var command = new SqlCommand('sp_AddEventTemp', connection)
{
CommandType = CommandType.StoredProcedure
};
command.Parameters.Add(new SqlParameter("@iUserID", userId)
{
Direction = ParameterDirection.Input,
SqlDbType = SqlDbType.Int
});
command.Parameters.Add(new SqlParameter("@iVerb", verb)
{
Direction = ParameterDirection.Input,
SqlDbType = SqlDbType.Int
});
command.Parameters.Add(new SqlParameter("@iObject", objectId)
{
Direction = ParameterDirection.Input,
SqlDbType = SqlDbType.Int
});
command.Parameters.Add(new SqlParameter("@iResult", 0)
{
Direction = ParameterDirection.Input,
SqlDbType = SqlDbType.Int
});
command.Parameters.Add(new SqlParameter("@nTransactionID", 0)
{
Direction = ParameterDirection.Output,
SqlDbType = SqlDbType.Int
});
// execute
connection.Open();
transactionId = (int)command.ExecuteScalar();
connection.Close();
}
return transactionId;
我也得到:
Procedure or function 'sp_AddEventTemp' expects parameter '@iResult' which was not supplied
即使它显然是供应!
我做了这个测试通过直接的SQL服务器上运行此:
sp_AddEventTemp 9530, 2, 15, 0, 0
它完美地工作。我得到了:(1 row(s) affected)
因此,存储过程本身没有任何问题。代码中必须有一些东西,我无法弄清楚,因为它看起来对我来说是正确的。
我对其他类似的存储过程做同样的事情,他们都工作正常。
任何想法?
在此先感谢
不要这样想,因为没有SqlDbType.Numberic这样的东西 这对我来说仍然是一个谜,但我通过使用解决方法得到它的工作 – Nick 2015-03-18 10:19:44