4

ストアドプロシージャに出力パラメータを提供したい。この出力プロシージャはを返し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).

何か案は?ありがとう

4

2 に答える 2

4

戻りサイズがわからない場合は、-1 を使用します。

New SqlParameter("@PreviewImage", SqlDbType.VarBinary) With {.Direction = ParameterDirection.Output, .Size = -1}

これにより、任意のサイズが返されます。

于 2011-09-21T13:34:50.500 に答える
2

Size パラメーターに値を指定する必要があります。

 new SqlParameter("@Bytes", SqlDbType.VarBinary, 8000)
于 2010-06-14T10:10:26.100 に答える