Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Size property has an invalid size of 0

You need to define a length when specifying the varchar parameter:

SqlParameter job1 = cmd2.Parameters.Add("@job", SqlDbType.VarChar, 50);

You should use the same length as defined in your SQL Server stored procedure.

And btw: if your stored procedure also has no length defined (something like @job VARCHAR OUTPUT) - then you've defined a varchar string of 1 character length ......


Yes, have to define the length for varchar / nvarchar data type like below.

cmd.Parameters.Add("@Description", SqlDbType.VarChar, 150).Direction =
    ParameterDirection.Output;

If you are using Dapper, you have passed in a null value for the parameter, where the expected input was a string.

To find the offending value and it's parameter, inspect at the Dapper DynamicParameters object during a debug session and open the parameters being index referred to.

enter image description here


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!