Asp.net mvc 4 过程或函数需要未提供的参数-但提供了参数

Asp.net mvc 4 过程或函数需要未提供的参数-但提供了参数,asp.net-mvc-4,c#-4.0,stored-procedures,sql-server-2012,Asp.net Mvc 4,C# 4.0,Stored Procedures,Sql Server 2012,我有一个看似常见的问题,但没有任何明显的错误 我已经看到了所有相关的线程,我看不出与我的问题有什么相似之处,因为我没有犯任何“明显”的错误,至少与其他线程不相似 我的存储过程声明: CREATE PROCEDURE [dbo].[sp_AddEventTemp] @iUserID int, @iVerb int, @iObject int, @iResult int, @nTransactionID numeric Output 以及守则: var us

我有一个看似常见的问题,但没有任何明显的错误

我已经看到了所有相关的线程,我看不出与我的问题有什么相似之处,因为我没有犯任何“明显”的错误,至少与其他线程不相似

我的存储过程声明:

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 server上运行此测试:

sp_AddEventTemp 9530, 2, 15, 0, 0
它工作得很好。我得到:
(1行受影响)

因此,存储过程本身没有问题。代码中一定有什么东西,我想不出来,因为我觉得它是正确的

我对其他类似的存储过程也这样做,它们都工作得很好

有什么想法吗


提前感谢

由于@nTransactionID的过程数据类型与您在代码中使用的数据类型(numeric/int)不匹配,这可能是某种后续错误吗?

不这样认为,因为没有SqlDbType。numeric这对我来说仍然是个谜,但我通过使用一种变通方法使它工作起来