2010-06-14 3 views
2

저장 프로 시저에 출력 매개 변수를 제공하려고합니다. 이 출력 proc은 byte[]을 반환합니다. 어떻게해야합니까?sqlparametercollection에 출력 매개 변수를 제공하여 오류가 발생했습니다 (Varbinary)

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). 

어떤 아이디어를 다음 작업을 수행 할 경우

? 감사

답변

2

당신은 크기 매개 변수 값을 제공해야합니다 : 당신이 반환 크기를 알 수없는 경우

new SqlParameter("@Bytes", SqlDbType.VarBinary, 8000) 
3

후 사용 -1, 예를

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

그러면 크기를 반환합니다.