0

尝试通过存储过程更新数据库中的行时出现此错误

过程或函数“sp_A_Update”需要未提供的参数“@Misc”。

但我已经提供了这个:

command.Parameters.AddWithValue("@Misc", inspection.Misc);

这是我的整个代码,其中删除了其他参数以缩短

using (SqlCommand command = new SqlCommand("sp_Agent_Inspection_Update", new SqlConnection (Configuration.ConnectionString)))
{
    command.CommandType = CommandType.StoredProcedure;

    PropertyInfo[] propertyInfo = inspection.GetType().GetProperties();

    command.Parameters.AddWithValue("@Misc", inspection.Misc);
    (lots of other params here...)
    command.Parameters.AddWithValue("@RepairNotes", inspection.RepairNotes);

    // OPEN CONNECTION
    command.Connection.Open();

    // EXECUTE QUERY
    int rowsAffected =  command.ExecuteNonQuery();

    command.Connection.Close();
    return Boolean.Parse(rowsAffected.ToString());
}

有没有人有任何想法?

4

1 回答 1

0

除了关于您正在调用的存储过程名称的明显错误之外。

识别和解决此问题的最简单方法是运行 SQL Profiler。在执行代码时进行跟踪,看看你传递给 SQL 的内容,你会看到它期望什么。

于 2012-05-10T01:20:36.280 回答