我想为我的存储过程提供一个输出参数。此输出过程返回 byte[]
。我该怎么做呢?
如果我执行以下操作:
command.Parameters.Add(new SqlParameter("@Bytes", SqlDbType.VarBinary));
command.Parameters[1].Direction = ParameterDirection.Output;
我得到:
System.InvalidOperationException: Byte[][1]: the Size property has an invalid size of 0. This stored proc works fine in SQL Server when I execute it via the SSMS option "Execute Stored Procedure).
有什么想法吗? 谢谢
最佳答案
如果您不知道返回大小,则使用 -1,例如
New SqlParameter("@PreviewImage", SqlDbType.VarBinary) With {.Direction = ParameterDirection.Output, .Size = -1}
然后这将返回任何尺寸。
关于c# - 向 sqlparametercollection 提供输出参数导致错误 (Varbinary),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3036319/