gpt4 book ai didi

c# - 向 sqlparametercollection 提供输出参数导致错误 (Varbinary)

转载 作者:行者123 更新时间:2023-11-30 15:10:41 24 4
gpt4 key购买 nike

我想为我的存储过程提供一个输出参数。此输出过程返回 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com