ADO.NET - The Size property has an invalid size of 0

前端 未结 10 1019
小蘑菇
小蘑菇 2020-12-14 13:41

I\'m trying to get output value from DB via ADO.NET. There\'s a client code:

    using (var connection = new SqlConnection(ConnectionString))
    {
                


        
10条回答
  •  遥遥无期
    2020-12-14 14:32

    Parameter Size is required for variable size Output parameters. Generally ADO.NET decides the size of the parameter based on the Value assigned to the parameter (hence it is optional), but in output parameter since no value is Set, you need provide the size required for the parameter

    Set the Parameter size to size of the output variable from the DB... Say 50

    outParam.Size = 50;
    

提交回复
热议问题